View Issue Details

IDProjectCategoryView StatusLast Update
0018956LazarusIDEpublic2011-11-25 10:11
ReporterStephanoAssigned ToZeljan Rikalo 
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Product Version0.9.31 (SVN)Product Build 
Target VersionFixed in Version 
Summary0018956: Right click/close in the source editor and the IDE crashes
DescriptionRight click/close in the source editor and the IDE crashes
TagsNo tags attached.
Fixed in Revision
LazTarget-
WidgetsetGTK 2
Attached Files
  • gkt_mouse.diff (1,052 bytes)
    Index: lcl/interfaces/gtk2/gtk2callback.inc
    ===================================================================
    --- lcl/interfaces/gtk2/gtk2callback.inc	(revisión: 30187)
    +++ lcl/interfaces/gtk2/gtk2callback.inc	(copia de trabajo)
    @@ -1547,6 +1547,7 @@
         if Event^.button = 1 then
         begin
           //CaptureMouseForWidget(CaptureWidget,mctGTKIntf);
    +      DeliverMouseDownMessage(Widget, Event, TWinControl(Data));
         end
         else
         // if LCL process LM_CONTEXTMENU then stop the event propagation
    @@ -1555,6 +1556,7 @@
           W := Widget;
           gdk_display_get_pointer(gtk_widget_get_display(Widget), nil, @x, @y, nil);
           Old := nil;
    +      DeliverMouseDownMessage(Widget, Event, TWinControl(Data));
           while W <> nil do
           begin
             Info := GetWidgetInfo(W);
    @@ -1603,7 +1605,7 @@
         end;
       end;
       //debugln('[gtkMouseBtnPress] calling DeliverMouseDownMessage Result=',dbgs(Result));
    -  DeliverMouseDownMessage(Widget, Event, TWinControl(Data));
    +  DeliverMouseUpMessage(Widget, Event, TWinControl(Data));
     end;
     
     
    
    gkt_mouse.diff (1,052 bytes)
  • gkt_mouse2.diff (1,046 bytes)
    Index: lcl/interfaces/gtk2/gtk2callback.inc
    ===================================================================
    --- lcl/interfaces/gtk2/gtk2callback.inc	(revisión: 30187)
    +++ lcl/interfaces/gtk2/gtk2callback.inc	(copia de trabajo)
    @@ -1555,6 +1555,7 @@
           W := Widget;
           gdk_display_get_pointer(gtk_widget_get_display(Widget), nil, @x, @y, nil);
           Old := nil;
    +      DeliverMouseDownMessage(Widget, Event, TWinControl(Data));
           while W <> nil do
           begin
             Info := GetWidgetInfo(W);
    @@ -1587,7 +1588,6 @@
             Mess.msg := LM_SelChange;
             DeliverMessage(TWinControl(Data), Mess);
           end;
    -
         end;
       end else begin
         if (event^.Button=1) and
    @@ -1603,7 +1603,8 @@
         end;
       end;
       //debugln('[gtkMouseBtnPress] calling DeliverMouseDownMessage Result=',dbgs(Result));
    -  DeliverMouseDownMessage(Widget, Event, TWinControl(Data));
    +  if (event^.Button=3) then DeliverMouseUpMessage(Widget, Event, TWinControl(Data))
    +  else DeliverMouseDownMessage(Widget, Event, TWinControl(Data));
     end;
     
     
    
    gkt_mouse2.diff (1,046 bytes)
  • gkt_mouse3.diff (1,419 bytes)
    Index: lcl/interfaces/gtk2/gtk2callback.inc
    ===================================================================
    --- lcl/interfaces/gtk2/gtk2callback.inc	(revisión: 30187)
    +++ lcl/interfaces/gtk2/gtk2callback.inc	(copia de trabajo)
    @@ -1555,6 +1555,7 @@
           W := Widget;
           gdk_display_get_pointer(gtk_widget_get_display(Widget), nil, @x, @y, nil);
           Old := nil;
    +      DeliverMouseDownMessage(Widget, Event, TWinControl(Data));
           while W <> nil do
           begin
             Info := GetWidgetInfo(W);
    @@ -1568,7 +1569,11 @@
               Msg.YPos := y;
     
               Result := DeliverMessage(Old, Msg) <> 0;
    -          if Result then break;
    +          if Result then
    +          begin
    +          DeliverMouseUpMessage(Widget, Event, TWinControl(Data));
    +          break;
    +          end;
             end;
             // check if widget has a standard popup menu
             if (W = widget) and Assigned(GTK_WIDGET_GET_CLASS(W)^.popup_menu) then
    @@ -1587,7 +1592,6 @@
             Mess.msg := LM_SelChange;
             DeliverMessage(TWinControl(Data), Mess);
           end;
    -
         end;
       end else begin
         if (event^.Button=1) and
    @@ -1603,7 +1607,8 @@
         end;
       end;
       //debugln('[gtkMouseBtnPress] calling DeliverMouseDownMessage Result=',dbgs(Result));
    -  DeliverMouseDownMessage(Widget, Event, TWinControl(Data));
    +  if (event^.Button=3) then
    +  else DeliverMouseDownMessage(Widget, Event, TWinControl(Data));
     end;
     
     
    
    gkt_mouse3.diff (1,419 bytes)

Relationships

related to 0018966 closedFelipe Monteiro de Carvalho Mouse down event of right click on TTreeView is sent after popup 
related to 0019798 resolvedMartin Friebe exception when closing source page 

Activities

Zeljan Rikalo

2011-03-20 18:04

developer   ~0046705

Probably by recent changed with menus.

Mark Z

2011-03-21 05:22

reporter   ~0046713

Depends on the desktop setup, so more info needed... The context menu hasn't worked for awhile, if ever, on Win32/64 when you put edit window on a different monitor from the menubar. Expect linux version would exhibit same behavior, but haven't tried it recently.

Paul Ishenin

2011-03-21 06:52

manager   ~0046716

What is "right click/close"? Do you mean "Close page" in the editor menu or something else?

Stephano

2011-03-21 12:18

developer   ~0046726

@Mark, Ubuntu 10.04

@Paul, click on 'close page' in the editor context menu

Martin Friebe

2011-03-21 15:16

manager   ~0046732

Some info:
- You need to have more than one tab open.
- You must *not* have viewed the SynEdit/Tab that will be activated *after* the current editor closed.

So best to just have opened Lazarus, and never have switched any tabs

The exception is
TWinControl.CreateWnd SynEdit6:TIDESynEditor Parent=nil ERROR WndParent=0

 Stack trace:
  $081DF286 line 7270 of include/wincontrol.inc
  $086404A1 line 7709 of synedit.pp
  $081DEDD3 line 7186 of include/wincontrol.inc
  $086360C6 line 4279 of synedit.pp
  $081DFED4 line 7623 of include/wincontrol.inc
  $081DD548 line 6288 of include/wincontrol.inc
  $082A2CA2 line 1744 of gtk2/gtk2callback.inc
  $082A2A12 line 1596 of gtk2/gtk2callback.inc

The issue is:
in the IDE the creation of handles for SynEdit is deferred until there tab is shown. (This allows the SynEdits to scan highlights in IDLE; and the IDE to start much faster)

GTK2 asks for the handle in DeliverMouseDownMessage, which for some reason goes to the tab, that will be shown.

- Right-mouse-down / right-mouse-up => context menu shown
- hover over "close page"
- left mouse down to select "page down"
=> this is the mouse down that accesses the handle, it should be created, but I *guess* the TPAge hasn't got a handle yet?

navigate the context menu by keyboard, and select "close page" with enter-key => all fine

Mark Z

2011-03-31 09:35

reporter   ~0046999

Apologies... I hadn't tried it in awhile, and appears the symptoms I noted were fixed in some rev before .9.30 was released, as that doesn't exhibit it.

Zeljan Rikalo

2011-04-03 20:31

developer   ~0047135

We can check if TWinControl is ok inside mouse delivery routine, and then it doesn't crash ..

August Klein

2011-04-04 19:38

reporter   ~0047218

I upload a possible fix. It also fix 0018966 issue.

2011-04-04 19:39

 

gkt_mouse.diff (1,052 bytes)
Index: lcl/interfaces/gtk2/gtk2callback.inc
===================================================================
--- lcl/interfaces/gtk2/gtk2callback.inc	(revisión: 30187)
+++ lcl/interfaces/gtk2/gtk2callback.inc	(copia de trabajo)
@@ -1547,6 +1547,7 @@
     if Event^.button = 1 then
     begin
       //CaptureMouseForWidget(CaptureWidget,mctGTKIntf);
+      DeliverMouseDownMessage(Widget, Event, TWinControl(Data));
     end
     else
     // if LCL process LM_CONTEXTMENU then stop the event propagation
@@ -1555,6 +1556,7 @@
       W := Widget;
       gdk_display_get_pointer(gtk_widget_get_display(Widget), nil, @x, @y, nil);
       Old := nil;
+      DeliverMouseDownMessage(Widget, Event, TWinControl(Data));
       while W <> nil do
       begin
         Info := GetWidgetInfo(W);
@@ -1603,7 +1605,7 @@
     end;
   end;
   //debugln('[gtkMouseBtnPress] calling DeliverMouseDownMessage Result=',dbgs(Result));
-  DeliverMouseDownMessage(Widget, Event, TWinControl(Data));
+  DeliverMouseUpMessage(Widget, Event, TWinControl(Data));
 end;
 
 
gkt_mouse.diff (1,052 bytes)

2011-04-04 21:19

 

gkt_mouse2.diff (1,046 bytes)
Index: lcl/interfaces/gtk2/gtk2callback.inc
===================================================================
--- lcl/interfaces/gtk2/gtk2callback.inc	(revisión: 30187)
+++ lcl/interfaces/gtk2/gtk2callback.inc	(copia de trabajo)
@@ -1555,6 +1555,7 @@
       W := Widget;
       gdk_display_get_pointer(gtk_widget_get_display(Widget), nil, @x, @y, nil);
       Old := nil;
+      DeliverMouseDownMessage(Widget, Event, TWinControl(Data));
       while W <> nil do
       begin
         Info := GetWidgetInfo(W);
@@ -1587,7 +1588,6 @@
         Mess.msg := LM_SelChange;
         DeliverMessage(TWinControl(Data), Mess);
       end;
-
     end;
   end else begin
     if (event^.Button=1) and
@@ -1603,7 +1603,8 @@
     end;
   end;
   //debugln('[gtkMouseBtnPress] calling DeliverMouseDownMessage Result=',dbgs(Result));
-  DeliverMouseDownMessage(Widget, Event, TWinControl(Data));
+  if (event^.Button=3) then DeliverMouseUpMessage(Widget, Event, TWinControl(Data))
+  else DeliverMouseDownMessage(Widget, Event, TWinControl(Data));
 end;
 
 
gkt_mouse2.diff (1,046 bytes)

August Klein

2011-04-04 21:25

reporter   ~0047225

New patch.
With previous one I'm unable to select text.

Zeljan Rikalo

2011-04-05 08:38

developer   ~0047233

@August are you sure that this patch is correct ? What if there's no context menu ? MouseUP is sent twice ? Once from here , and once from real mouseup method ? Have you tested such scenario ?

August Klein

2011-04-05 10:37

reporter   ~0047235

Last edited: 2011-04-05 10:46

@Zeljan You are right. If context menu does not exist then MouseUp is fired twice.

Let me one last try. New patch avoid that. I's not easy test every scenario, and I have not a deep knowledge of LCL.

2011-04-05 10:38

 

gkt_mouse3.diff (1,419 bytes)
Index: lcl/interfaces/gtk2/gtk2callback.inc
===================================================================
--- lcl/interfaces/gtk2/gtk2callback.inc	(revisión: 30187)
+++ lcl/interfaces/gtk2/gtk2callback.inc	(copia de trabajo)
@@ -1555,6 +1555,7 @@
       W := Widget;
       gdk_display_get_pointer(gtk_widget_get_display(Widget), nil, @x, @y, nil);
       Old := nil;
+      DeliverMouseDownMessage(Widget, Event, TWinControl(Data));
       while W <> nil do
       begin
         Info := GetWidgetInfo(W);
@@ -1568,7 +1569,11 @@
           Msg.YPos := y;
 
           Result := DeliverMessage(Old, Msg) <> 0;
-          if Result then break;
+          if Result then
+          begin
+          DeliverMouseUpMessage(Widget, Event, TWinControl(Data));
+          break;
+          end;
         end;
         // check if widget has a standard popup menu
         if (W = widget) and Assigned(GTK_WIDGET_GET_CLASS(W)^.popup_menu) then
@@ -1587,7 +1592,6 @@
         Mess.msg := LM_SelChange;
         DeliverMessage(TWinControl(Data), Mess);
       end;
-
     end;
   end else begin
     if (event^.Button=1) and
@@ -1603,7 +1607,8 @@
     end;
   end;
   //debugln('[gtkMouseBtnPress] calling DeliverMouseDownMessage Result=',dbgs(Result));
-  DeliverMouseDownMessage(Widget, Event, TWinControl(Data));
+  if (event^.Button=3) then
+  else DeliverMouseDownMessage(Widget, Event, TWinControl(Data));
 end;
 
 
gkt_mouse3.diff (1,419 bytes)

Zeljan Rikalo

2011-04-05 11:52

developer   ~0047238

That one looks better, but must be heavy tested.Also, there's case when context menu is handled by gtk2 itself (eg. context menu of TEdit).

Zeljan Rikalo

2011-07-04 17:46

developer   ~0049655

@August, cannot apply gkt_mouse3 patch , there are errors (seem that some code is added in the meantime). Can you review and attach correct patch so I can test ?

August Klein

2011-07-04 22:13

reporter   ~0049671

@Zeljan, note that Mattias applied a patch for this issue (just for testing). See last note in 0018966

Revision was 30939:

http://svn.freepascal.org/cgi-bin/viewvc.cgi?view=rev&root=lazarus&revision=30939

If it doesn't work, I can rewrite my patch.

Martin Friebe

2011-11-14 14:44

manager   ~0054073

Does the the issue still occur?

I can no longer reproduce, however 0019798 was created after the last note by A. Klein. And I can not reproduce 0019798 either.

Zeljan Rikalo

2011-11-20 11:06

developer   ~0054292

Cannot reproduce with Lazarus 0.9.31 r33640 FPC 2.4.5 i386-linux-gtk 2.
Please retest, and reopen if it isn't so.

Stephano

2011-11-25 10:11

developer   ~0054442

Fixed

Issue History

Date Modified Username Field Change
2011-03-20 17:47 Stephano New Issue
2011-03-20 17:47 Stephano Widgetset => GTK 2
2011-03-20 18:04 Zeljan Rikalo Note Added: 0046705
2011-03-21 05:22 Mark Z Note Added: 0046713
2011-03-21 06:52 Paul Ishenin LazTarget => -
2011-03-21 06:52 Paul Ishenin Note Added: 0046716
2011-03-21 06:52 Paul Ishenin Status new => feedback
2011-03-21 12:18 Stephano Note Added: 0046726
2011-03-21 15:16 Martin Friebe Note Added: 0046732
2011-03-22 14:20 Mattias Gaertner Relationship added related to 0018966
2011-03-31 09:35 Mark Z Note Added: 0046999
2011-04-03 20:31 Zeljan Rikalo Note Added: 0047135
2011-04-04 19:38 August Klein Note Added: 0047218
2011-04-04 19:39 August Klein File Added: gkt_mouse.diff
2011-04-04 21:19 August Klein File Added: gkt_mouse2.diff
2011-04-04 21:25 August Klein Note Added: 0047225
2011-04-05 08:38 Zeljan Rikalo Note Added: 0047233
2011-04-05 10:37 August Klein Note Added: 0047235
2011-04-05 10:38 August Klein File Added: gkt_mouse3.diff
2011-04-05 10:46 August Klein Note Edited: 0047235
2011-04-05 11:52 Zeljan Rikalo Note Added: 0047238
2011-07-04 17:46 Zeljan Rikalo Note Added: 0049655
2011-07-04 17:46 Zeljan Rikalo Status feedback => acknowledged
2011-07-04 22:13 August Klein Note Added: 0049671
2011-11-14 14:35 Martin Friebe Relationship added related to 0019798
2011-11-14 14:44 Martin Friebe Note Added: 0054073
2011-11-20 11:06 Zeljan Rikalo Status acknowledged => resolved
2011-11-20 11:06 Zeljan Rikalo Resolution open => fixed
2011-11-20 11:06 Zeljan Rikalo Assigned To => Zeljan Rikalo
2011-11-20 11:06 Zeljan Rikalo Note Added: 0054292
2011-11-25 10:11 Stephano Status resolved => closed
2011-11-25 10:11 Stephano Note Added: 0054442