View Issue Details

IDProjectCategoryView StatusLast Update
0026466LazarusWidgetsetpublic2014-07-13 20:15
ReporterVojtech Cihak Assigned ToZeljan Rikalo  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformamd64OSLinux 
Product Version1.3 (SVN) 
Summary0026466: [Qt4] Drag and drop operation crashes
DescriptionDrag and drop operation crashes with TToolBar. The same works with GTK2. Also, it works well with TEdit or TButton. Call Stack shows crash somewhere deep in the widgetset.
Steps To ReproduceRun demo. Push button over upper Panel1 and release it over Panel2.
Additional InformationLazarus 1.3 r45807M FPC 2.7.1 x86_64-linux-qt
TagsNo tags attached.
Fixed in Revision45820,45856
LazTarget-
WidgetsetQT
Attached Files

Activities

Vojtech Cihak

2014-07-09 17:59

reporter  

DragAndDrop.zip (6,522 bytes)

Vojtech Cihak

2014-07-09 19:41

reporter   ~0076160

When I already mentioned the Call Stack, here is output:

#0 QWidget::testAttribute_helper(Qt::WidgetAttribute) const at :0
0000001 QWidget::setAttribute(Qt::WidgetAttribute, bool) at :0
0000002 SETNOMOUSEPROPAGATION(0x7ffff7f87b30, 0xc62790, true) at qt/qtwidgets.pas:2674
0000003 SLOTMOUSE(0x7ffff7f87b30, 0xc62790, 0x7fffffffdb80) at qt/qtwidgets.pas:3578
0000004 EVENTFILTER(0x7ffff7f87b30, 0xc62790, 0x7fffffffdb80) at qt/qtwidgets.pas:2534
0000005 EVENTFILTER(0x7ffff7f87b30, 0xc62790, 0x7fffffffdb80) at qt/qtwidgets.pas:15619
0000006 VIEWPORTEVENTFILTER(0x7ffff7f87870, 0x7fffffffdb80, 0x7fffffffd7bf) at qt/qtwidgets.pas:16105
0000007 QLCLAbstractScrollArea::viewportEvent(QEvent*) at :0
0000008 QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) at :0
0000009 QApplicationPrivate::notify_helper(QObject*, QEvent*) at :0
0000010 QApplication::notify(QObject*, QEvent*) at :0
0000011 QCoreApplication::notifyInternal(QObject*, QEvent*) at :0
0000012 QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) at :0
0000013 ?? at :0
0000014 QApplication::x11ProcessEvent(_XEvent*) at :0
0000015 ?? at :0
0000016 g_main_context_dispatch at :0
0000017 ?? at :0
0000018 g_main_context_iteration at :0
0000019 QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) at :0
0000020 ?? at :0
0000021 QCoreApplication::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) at :0
0000022 QCoreApplication_processEvents at :0
0000023 APPWAITMESSAGE(0x7ffff7f58850) at qt/qtobject.inc:287
0000024 IDLE(0x7ffff7f583b0, true) at include/application.inc:412
0000025 HANDLEMESSAGE(0x7ffff7f583b0) at include/application.inc:1265
0000026 RUNLOOP(0x7ffff7f583b0) at include/application.inc:1399
0000027 APPRUN(0x7ffff7f58850, {Proc = {procedure (POINTER)} 0x7fffffffe400, Self = 0x7ffff7f583b0}) at qt/qtobject.inc:270
0000028 RUN(0x7ffff7f583b0) at include/application.inc:1387
0000029 main at project1.lpr:19

Zeljan Rikalo

2014-07-09 20:56

developer   ~0076162

Please test and close if ok.

Vojtech Cihak

2014-07-09 21:17

reporter   ~0076163

Unfortunately, I got the same crash with 45820 (and thesame output from Call Stack).

Zeljan Rikalo

2014-07-10 07:53

developer   ~0076165

ok, I'll check on 64bit, since 32bit does not crash anymore.

Zeljan Rikalo

2014-07-10 15:39

developer   ~0076166

@Vojtech, can you add FDeleteLater := True at the bottom of TQtCustomControl.CreateWidget and see if it still crashes ?

Vojtech Cihak

2014-07-10 16:31

reporter   ~0076167

It's better but still sometimes crashes. While simple demo works well, when I add a few components and a few toolbuttons to the toolbar, it crashes again. I uploaded DragAndDrop2.zip demo that shows it.

Vojtech Cihak

2014-07-10 20:05

reporter  

DragAndDrop2.zip (8,028 bytes)

Vojtech Cihak

2014-07-10 20:06

reporter   ~0076168

Sorry for delay with uploading the second demo. Bugtracker is often down today.

Zeljan Rikalo

2014-07-10 20:19

developer  

26466.diff (654 bytes)   
Index: lcl/interfaces/qt/qtwidgets.pas
===================================================================
--- lcl/interfaces/qt/qtwidgets.pas	(revision 45820)
+++ lcl/interfaces/qt/qtwidgets.pas	(working copy)
@@ -15916,7 +15916,6 @@
   if Sender = viewportWidget then
     inherited SetNoMousePropagation(Sender, False)
   else
-  if Sender = Widget then
     inherited SetNoMousePropagation(Sender, ANoMousePropagation);
 end;
 
@@ -16007,6 +16006,7 @@
     QWidget_setAutoFillBackground(Result, False);
 
   QWidget_setAttribute(Result, QtWA_InputMethodEnabled);
+  FDeleteLater := True;
 end;
 
 function TQtCustomControl.ProcessArrowKeys: Boolean;
26466.diff (654 bytes)   

Zeljan Rikalo

2014-07-10 20:19

developer   ~0076170

Please test with attached patch. I cannot reproduce any crash.

Vojtech Cihak

2014-07-10 20:50

reporter   ~0076171

The second demo still crashes here with 26466.patch applied.

Vojtech Cihak

2014-07-10 20:54

reporter   ~0076172

The Call stack is a little different:

#0 fpc_check_object at :0
0000001 ?? at :0
0000002 CANSENDLCLMESSAGE(0x7ffff7f87b30) at qt/qtwidgets.pas:2201
0000003 SLOTMOUSE(0x7ffff7f87b30, 0xcf9aa0, 0x7fffffffdb80) at qt/qtwidgets.pas:3577
0000004 EVENTFILTER(0x7ffff7f87b30, 0xcf9aa0, 0x7fffffffdb80) at qt/qtwidgets.pas:2534
0000005 EVENTFILTER(0x7ffff7f87b30, 0xcf9aa0, 0x7fffffffdb80) at qt/qtwidgets.pas:15619
0000006 VIEWPORTEVENTFILTER(0x7ffff7f87870, 0x7fffffffdb80, 0x7fffffffd7bf) at qt/qtwidgets.pas:16108

and the rest is the same.

Zeljan Rikalo

2014-07-11 15:15

developer   ~0076180

Cannot reproduce under 32 or 64 bit. What fpc version do you have ? I've been testing using 2.6.2 and 2.6.4

Vojtech Cihak

2014-07-11 15:27

reporter   ~0076181

Last edited: 2014-07-11 16:08

View 2 revisions

I have 2.7.1.

I tried with 2.6.4 and it crashes too.

Zeljan Rikalo

2014-07-12 10:06

developer  

26466_2.diff (786 bytes)   
Index: lcl/interfaces/qt/qtwidgets.pas
===================================================================
--- lcl/interfaces/qt/qtwidgets.pas	(revision 45824)
+++ lcl/interfaces/qt/qtwidgets.pas	(working copy)
@@ -15916,7 +15916,6 @@
   if Sender = viewportWidget then
     inherited SetNoMousePropagation(Sender, False)
   else
-  if Sender = Widget then
     inherited SetNoMousePropagation(Sender, ANoMousePropagation);
 end;
 
@@ -16024,6 +16023,12 @@
   {$ifdef VerboseQt}
     WriteLn('TQtCustomControl.Destroy');
   {$endif}
+  if InEvent or (Assigned(FViewPortWidget) and FViewPortWidget.InEvent) then
+  begin
+    FDeleteLater := True;
+    if Assigned(FViewPortWidget) then
+      FViewPortWidget.FDeleteLater := True;
+  end;
   viewportDelete;
   inherited Destroy;
 end;
26466_2.diff (786 bytes)   

Zeljan Rikalo

2014-07-12 10:08

developer   ~0076188

Attached new patch 26466_2.diff.
I cannot reproduce crash without previous and without this patch.Tested on few machines 32/64 bit, various distributions.
libQt4Pas is distro one or you build it by yourself ? Qt version ?

Vojtech Cihak

2014-07-12 10:59

reporter   ~0076189

Qt 4.8.6, 64-bit, libQt4pas.so is distro version.
26466_2.diff still crashes

#0 fpc_check_object at :0
0000001 ?? at :0
0000002 CANSENDLCLMESSAGE(0x7ffff7f87b30) at qt/qtwidgets.pas:2201
0000003 SLOTMOUSE(0x7ffff7f87b30, 0xcf2a90, 0x7fffffffdb80) at qt/qtwidgets.pas:3577
0000004 EVENTFILTER(0x7ffff7f87b30, 0xcf2a90, 0x7fffffffdb80) at qt/qtwidgets.pas:2534
0000005 EVENTFILTER(0x7ffff7f87b30, 0xcf2a90, 0x7fffffffdb80) at qt/qtwidgets.pas:15619
0000006 VIEWPORTEVENTFILTER(0x7ffff7f87870, 0x7fffffffdb80, 0x7fffffffd7bf) at qt/qtwidgets.pas:16113
0000007 QLCLAbstractScrollArea::viewportEvent(QEvent*) at :0
0000008 QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) at :0
0000009 QApplicationPrivate::notify_helper(QObject*, QEvent*) at :0
0000010 QApplication::notify(QObject*, QEvent*) at :0
0000011 QCoreApplication::notifyInternal(QObject*, QEvent*) at :0
0000012 QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) at :0
0000013 ?? at :0
0000014 QApplication::x11ProcessEvent(_XEvent*) at :0
0000015 ?? at :0
0000016 g_main_context_dispatch at :0
0000017 ?? at :0
0000018 g_main_context_iteration at :0
0000019 QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) at :0
0000020 ?? at :0
0000021 QCoreApplication::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) at :0
0000022 QCoreApplication_processEvents at :0
0000023 APPWAITMESSAGE(0x7ffff7f58850) at qt/qtobject.inc:287
0000024 IDLE(0x7ffff7f583b0, true) at include/application.inc:412
0000025 HANDLEMESSAGE(0x7ffff7f583b0) at include/application.inc:1265
0000026 RUNLOOP(0x7ffff7f583b0) at include/application.inc:1399
0000027 APPRUN(0x7ffff7f58850, {Proc = {procedure (POINTER)} 0x7fffffffe400, Self = 0x7ffff7f583b0}) at qt/qtobject.inc:270
0000028 RUN(0x7ffff7f583b0) at include/application.inc:1387
0000029 main at project1.lpr:19

Zeljan Rikalo

2014-07-12 11:33

developer   ~0076190

Ok, please try to move "and getVisible" at the end of statement in TQtWidget.CanSendLCLMessage();

  Result := (LCLObject <> nil) and (Widget <> nil) and getVisible and
    not ((csDestroying in LCLObject.ComponentState) or
         (csDestroyingHandle in LCLObject.ControlState));

  Result := (LCLObject <> nil) and (Widget <> nil) and
    not ((csDestroying in LCLObject.ComponentState) or
         (csDestroyingHandle in LCLObject.ControlState)) and getVisible;

I'll bet that something is wrong with your libQt4Pas.

Zeljan Rikalo

2014-07-12 11:38

developer   ~0076191

Also, can you add writeln() line TQtWidget.SlotMouse around DeliverMessage() in line 3577 like this:
writeln('Delivering: ',dbgHex(PtrUint(Sender)));
DeliverMessage(Msg, True);
writeln('Delivered: ',dbgHex(PtrUint(Sender)));

Zeljan Rikalo

2014-07-12 11:46

developer  

26466_3.diff (1,649 bytes)   
Index: lcl/interfaces/qt/qtwidgets.pas
===================================================================
--- lcl/interfaces/qt/qtwidgets.pas	(revision 45837)
+++ lcl/interfaces/qt/qtwidgets.pas	(working copy)
@@ -3416,6 +3416,7 @@
   MousePos: TQtPoint;
   MButton: QTMouseButton;
   Modifiers: QtKeyboardModifiers;
+  SaveWidget: QWidgetH;
 
   function CheckMouseButtonDown(AButton: Integer): Cardinal;
 
@@ -3565,12 +3566,21 @@
         QtMidButton: Msg.Msg := LM_MBUTTONUP;
       end;
 
+      SaveWidget := nil;
+      if (FChildOfComplexWidget = ccwCustomControl) and (FOwner <> nil) then
+        SaveWidget := Widget;
+
       NotifyApplicationUserInput(LCLObject, Msg.Msg);
 
+      if (SaveWidget <> nil) and (SaveWidget <> Widget) then
+        exit(True);
+
       if not CanSendLCLMessage or (Sender = nil) then
         exit(True);
 
       DeliverMessage(Msg, True);
+      if (SaveWidget <> nil) and (SaveWidget <> Widget) then
+        exit(True);
 
       // Check if our objects exists since LCL can destroy object during
       // mouse events...
@@ -15916,7 +15926,6 @@
   if Sender = viewportWidget then
     inherited SetNoMousePropagation(Sender, False)
   else
-  if Sender = Widget then
     inherited SetNoMousePropagation(Sender, ANoMousePropagation);
 end;
 
@@ -16024,6 +16033,14 @@
   {$ifdef VerboseQt}
     WriteLn('TQtCustomControl.Destroy');
   {$endif}
+
+  if InEvent or (Assigned(FViewPortWidget) and FViewPortWidget.InEvent) then
+  begin
+    FDeleteLater := True;
+    if Assigned(FViewPortWidget) then
+      FViewPortWidget.FDeleteLater := True;
+  end;
+
   viewportDelete;
   inherited Destroy;
 end;
26466_3.diff (1,649 bytes)   

Zeljan Rikalo

2014-07-12 11:48

developer   ~0076192

Attached 26466_3.diff which checks state of widget inside mouse event. Please test if this one crashes. If it doesn't crash then please comment new code in TQtCustomControl.Destroy (before viewportDelete call) and then test again and see if it's suffficient to add widget check in SlotMouse().Again, I cannot reproduce any crash in both cases.

Vojtech Cihak

2014-07-13 00:18

reporter   ~0076202

I tried to move the "getVisible", code crashes here:

function TQtWidget.CanSendLCLMessage: Boolean;
begin
  Result := (LCLObject <> nil) and (Widget <> nil) and
=> not ((csDestroying in LCLObject.ComponentState) or
         (csDestroyingHandle in LCLObject.ControlState)) and getVisible;
end;

hovering identifier LCLObject shows $f0f0f0f0f0f0f0f0
                                                              
call stack:
#0 CANSENDLCLMESSAGE(0x7ffff7f87b30) at qt/qtwidgets.pas:2202
0000001 SLOTMOUSE(0x7ffff7f87b30, 0xceca50, 0x7fffffffdb80) at qt/qtwidgets.pas:3578
0000002 EVENTFILTER(0x7ffff7f87b30, 0xceca50, 0x7fffffffdb80) at qt/qtwidgets.pas:2534
0000003 EVENTFILTER(0x7ffff7f87b30, 0xceca50, 0x7fffffffdb80) at qt/qtwidgets.pas:15620

Thinking about libQt4pas, now I am not sure if it is distro version. Maybe it is downloaded from official website, it is version 5.2.5 from file bin64-qt4pas-V2.5_Qt4.5.3.tar.gz.

I'll try 26466_3.diff now.

Vojtech Cihak

2014-07-13 00:37

reporter   ~0076203

Last edited: 2014-07-13 17:31

View 2 revisions

26466_3.diff does not crash!
I tried to comment new code in TQtCustomControl.Destroy method and it does not crash too.

Can be resolved.

EDIT: I didn't know that this midnight post was submitted because bugtracker went down.

Zeljan Rikalo

2014-07-13 17:42

developer   ~0076204

No, it cannot be resolved until it's commited :)

Zeljan Rikalo

2014-07-13 17:48

developer   ~0076205

Please test and close if ok. I've removed part of code from TQtCustomControl.Destroy

Vojtech Cihak

2014-07-13 20:15

reporter   ~0076209

I tested with r.45856. Thanks and admiration, since you improved bug which you wasn't able to reproduce yourself.

Issue History

Date Modified Username Field Change
2014-07-09 17:59 Vojtech Cihak New Issue
2014-07-09 17:59 Vojtech Cihak File Added: DragAndDrop.zip
2014-07-09 19:41 Vojtech Cihak Note Added: 0076160
2014-07-09 20:39 Zeljan Rikalo Assigned To => Zeljan Rikalo
2014-07-09 20:39 Zeljan Rikalo Status new => assigned
2014-07-09 20:56 Zeljan Rikalo Fixed in Revision => 45820
2014-07-09 20:56 Zeljan Rikalo LazTarget => -
2014-07-09 20:56 Zeljan Rikalo Note Added: 0076162
2014-07-09 20:56 Zeljan Rikalo Status assigned => resolved
2014-07-09 20:56 Zeljan Rikalo Resolution open => fixed
2014-07-09 21:17 Vojtech Cihak Note Added: 0076163
2014-07-09 21:17 Vojtech Cihak Status resolved => assigned
2014-07-09 21:17 Vojtech Cihak Resolution fixed => reopened
2014-07-10 14:56 Zeljan Rikalo Note Added: 0076165
2014-07-10 19:49 Vojtech Cihak Note Added: 0076167
2014-07-10 19:49 Zeljan Rikalo Note Added: 0076166
2014-07-10 19:49 Zeljan Rikalo Status assigned => feedback
2014-07-10 20:05 Vojtech Cihak File Added: DragAndDrop2.zip
2014-07-10 20:06 Vojtech Cihak Note Added: 0076168
2014-07-10 20:06 Vojtech Cihak Status feedback => assigned
2014-07-10 20:19 Zeljan Rikalo File Added: 26466.diff
2014-07-10 20:19 Zeljan Rikalo Note Added: 0076170
2014-07-10 20:50 Vojtech Cihak Note Added: 0076171
2014-07-10 20:54 Vojtech Cihak Note Added: 0076172
2014-07-11 15:15 Zeljan Rikalo Note Added: 0076180
2014-07-11 15:15 Zeljan Rikalo Status assigned => feedback
2014-07-11 15:27 Vojtech Cihak Note Added: 0076181
2014-07-11 15:27 Vojtech Cihak Status feedback => assigned
2014-07-11 16:08 Vojtech Cihak Note Edited: 0076181 View Revisions
2014-07-12 10:06 Zeljan Rikalo File Added: 26466_2.diff
2014-07-12 10:08 Zeljan Rikalo Note Added: 0076188
2014-07-12 10:08 Zeljan Rikalo Status assigned => feedback
2014-07-12 10:59 Vojtech Cihak Note Added: 0076189
2014-07-12 10:59 Vojtech Cihak Status feedback => assigned
2014-07-12 11:33 Zeljan Rikalo Note Added: 0076190
2014-07-12 11:33 Zeljan Rikalo Status assigned => feedback
2014-07-12 11:38 Zeljan Rikalo Note Added: 0076191
2014-07-12 11:46 Zeljan Rikalo File Added: 26466_3.diff
2014-07-12 11:48 Zeljan Rikalo Note Added: 0076192
2014-07-13 00:18 Vojtech Cihak Note Added: 0076202
2014-07-13 00:18 Vojtech Cihak Status feedback => assigned
2014-07-13 07:38 Vojtech Cihak Note Added: 0076203
2014-07-13 17:31 Vojtech Cihak Note Edited: 0076203 View Revisions
2014-07-13 17:42 Zeljan Rikalo Note Added: 0076204
2014-07-13 17:48 Zeljan Rikalo Fixed in Revision 45820 => 45820,45856
2014-07-13 17:48 Zeljan Rikalo Note Added: 0076205
2014-07-13 17:48 Zeljan Rikalo Status assigned => resolved
2014-07-13 17:48 Zeljan Rikalo Resolution reopened => fixed
2014-07-13 20:15 Vojtech Cihak Note Added: 0076209
2014-07-13 20:15 Vojtech Cihak Status resolved => closed