Bug 159247 - [CRASH] Dialog editor crashes when inserting control with default options
Summary: [CRASH] Dialog editor crashes when inserting control with default options
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
7.6.4.1 release
Hardware: All All
: medium normal
Assignee: Rafael Lima
URL:
Whiteboard: target:24.8.0 target:24.2.1 target:7.6.5
Keywords: haveBacktrace
Depends on:
Blocks:
 
Reported: 2024-01-17 17:45 UTC by Rafael Lima
Modified: 2024-01-22 21:19 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
Backtrace (7.32 KB, text/x-log)
2024-01-17 17:47 UTC, Rafael Lima
Details
bt (5.61 KB, text/plain)
2024-01-17 18:52 UTC, Julien Nabet
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rafael Lima 2024-01-17 17:45:20 UTC
Steps to reproduce

1) From any LO app, open the Basic IDE (Tools - Macros - Edit Macros)
2) Create a new dialog (Dialog - Organize Dialogs - New)
3) Open the newly created dialog by double-clicking it in the Object Catalog
4) Insert a button with default settings (to do that, use the control toolbar; press the "Button" tool while holding the Ctrl key)
5) The new control will be created in the middle of the dialog
6) Now try to drag this control to position it anywhere else
7) CRASH

Problem happens in:

Version: 7.6.4.1 (X86_64) / LibreOffice Community
Build ID: 60(Build:1)
CPU threads: 16; OS: Linux 6.5; UI render: default; VCL: kf5 (cairo+xcb)
Locale: pt-BR (pt_BR.UTF-8); UI: en-US
Ubuntu package version: 4:7.6.4-0ubuntu0.23.10.1
Calc: threaded
Comment 1 Rafael Lima 2024-01-17 17:47:24 UTC
Created attachment 192020 [details]
Backtrace

This problem also happens in the current master.

Here's a backtrace using "make debugrun"

Version: 24.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 7850a7deb59b890c73dfd52bd5aced6a538e6349
CPU threads: 16; OS: Linux 6.5; UI render: default; VCL: kf5 (cairo+xcb)
Locale: pt-BR (pt_BR.UTF-8); UI: en-US
Calc: CL threaded
Comment 2 Julien Nabet 2024-01-17 18:52:49 UTC
Created attachment 192021 [details]
bt

On pc Debian x86-64 with master sources updated today, I could reproduce this.
I also noticed this log on console:
warn:legacy.tools:64615:64615:basctl/source/dlged/dlgedobj.cxx:143: lcl_getDlgEdForm: no form!
Comment 3 Julien Nabet 2024-01-17 19:17:47 UTC
With this patch, it doesn't crash and the button moves:
diff --git a/basctl/source/dlged/dlgedobj.cxx b/basctl/source/dlged/dlgedobj.cxx
index 5b87393e51bc..74e8fde38488 100644
--- a/basctl/source/dlged/dlgedobj.cxx
+++ b/basctl/source/dlged/dlgedobj.cxx
@@ -931,7 +931,8 @@ void DlgEdObj::NbcMove( const Size& rSize )
     StartListening();
 
     // dialog model changed
-    GetDlgEdForm()->GetDlgEditor().SetDialogModelChanged();
+    if (GetDlgEdForm())
+        GetDlgEdForm()->GetDlgEditor().SetDialogModelChanged();
 }
 
 void DlgEdObj::NbcResize(const Point& rRef, const Fraction& xFract, const Fraction& yFract)
@@ -948,7 +949,8 @@ void DlgEdObj::NbcResize(const Point& rRef, const Fraction& xFract, const Fracti
     StartListening();
 
     // dialog model changed
-    GetDlgEdForm()->GetDlgEditor().SetDialogModelChanged();
+    if (GetDlgEdForm())
+        GetDlgEdForm()->GetDlgEditor().SetDialogModelChanged();
 }
 
 bool DlgEdObj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)

(I can also resize it)

Now, as often, perhaps I'm just hiding the real pb.
Comment 4 Rafael Lima 2024-01-17 19:32:14 UTC
(In reply to Julien Nabet from comment #3)
> Now, as often, perhaps I'm just hiding the real pb.

So... the real problem is that the object does not have a parent form upon creation. The patch below fixes the problem:

diff --git a/basctl/source/dlged/dlged.cxx b/basctl/source/dlged/dlged.cxx
index 2eb099718b5b..a91a6511bd50 100644
--- a/basctl/source/dlged/dlged.cxx
+++ b/basctl/source/dlged/dlged.cxx
@@ -620,6 +620,8 @@ void DlgEditor::CreateDefaultObject()
 
     // set default property values
     pDlgEdObj->SetDefaults();
+    // set the form to which the new object belongs
+    pDlgEdObj->SetDlgEdForm(pDlgEdForm.get());
 
     // insert object into drawing page
     SdrPageView* pPageView = pDlgEdView->GetSdrPageView();

I'll publish it on Gerrit.
Comment 5 Rafael Lima 2024-01-17 19:55:43 UTC
Proposed patch here:

https://gerrit.libreoffice.org/c/core/+/162217
Comment 6 Commit Notification 2024-01-19 12:24:45 UTC
Rafael Lima committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/c4e5b1b934fc3c59fb35ae6c02a0ddf8501a6d28

tdf#159247 Fix crash while adding control with default properties (Dialog Editor)

It will be available in 24.8.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 7 Commit Notification 2024-01-19 16:09:20 UTC
Rafael Lima committed a patch related to this issue.
It has been pushed to "libreoffice-24-2":

https://git.libreoffice.org/core/commit/8472ffa70887b8f68d7e8f17faef377a83b0695e

tdf#159247 Fix crash while adding control with default properties (Dialog Editor)

It will be available in 24.2.1.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 8 Commit Notification 2024-01-22 21:19:46 UTC
Rafael Lima committed a patch related to this issue.
It has been pushed to "libreoffice-7-6":

https://git.libreoffice.org/core/commit/3fd80b31eb997847e04571b21ec512928a70bf81

tdf#159247 Fix crash while adding control with default properties (Dialog Editor)

It will be available in 7.6.5.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.