GNOME Bugzilla – Bug 351671
textview should stop selecting when losing focus
Last modified: 2007-06-07 03:48:06 UTC
Steps to reproduce: Assuming you already have a note titled, "Start Here"... 1. Create a new note 2. Highlight "New Note X" and type "Start Here" (do not hit enter) 3. Use your mouse to click on the "Describe your new note here." (or anywhere else below the title) 4. You'll get the "Note title taken" error message. Press the OK button 5. Now click with the mouse again on the "Describe your new note here." text (or anywhere else below the title) and Tomboy will crash. Stack trace: Gtk-ERROR **: file gtktextview.c: line 5685 (gtk_text_view_start_selection_drag): assertion failed: (text_view->selection_drag_handler == 0) aborting... Stack trace can be seen here: https://bugzilla.novell.com/attachment.cgi?id=84693&action=view Other information: Original bug filed here: https://bugzilla.novell.com/show_bug.cgi?id=177857 I started looking at this one but haven't figured out exactly what's going on. I noticed that even if I comment out the code in ShowNameClashError() (Watchers.cs) that highlights the title, the selection mode is in a weird state after dismissing the "Note title taken" error dialog. After dismissing the "Note title taken" dialog, the selection mode act like you have the mouse button pressed down and are attempting to highlight the existing text. I'm going to still attempt to look into this, but if anyone has any quick ideas, please feel free to jump in!
Very strange. I can duplicate this exactly. I suspect this didn't occur before the switch to GTK#2, though I'm not sure about that.
I've tracked this down to the following... If the ButtonReleaseEvent is not received by the Note's TextView before the "Note Taken" dialog is shown, there is problems. It puts the TextView into a selection mode. But, when the Note Taken dialog is closed, the selection is in a weird state and the following line in gtk_text_view_start_selection_drag () causes an assertion: g_assert (text_view->selection_drag_handler == 0); So, I've tried to: 1. Delay showing the Note Taken dialog using GLib.Timeout.Add (). This only works, however, if the user lets go of the mouse button before the Note Taken dialog is shown. If they don't let go in time, the crash will still happen. 2. Watch the ButtonPress and ButtonRelease events to keep track of when a mouse button is being held down. If it's held down, try simulating a mouse button release before opening the Note Taken dialog by using Gdk.EventHelper.New (Gdk.EventType.ButtonRelease). The problem here is that there doesn't seem to be a way to modify the Gdk.EventButton's structure to set Gdk.EventButton->Button = 1 (left click). So, even though I use Window.Editor.ProcessEvent (Gdk.EventHelper.New (Gdk.EventType.ButtonRelease), the TextView doesn't see this as a left-click and it still remains in the bad selection state. Anyone have any ideas of what else could be done? Should we override the selection drag stuff in the Window.Editor and allow the Watchers.cs to communicate directly with this to prevent this? I'm out of time tonight, but will give something else a shot next week.
This appears to be a bug in Gtk+. I've been chatting with Federico about this and I'm now creating a patch to gtktreeview.c that will hopefully take care of this by calling gtk_text_view_end_selection_drag () from gtk+/gtk/gtktextview.c:gtk_text_view_focus_out_event ().
I tried the method in comment #3 and the problem no longer happens. I'll attach a patch. This is a gtk+ bug, so I'm also reassigning it and updating the summary.
Created attachment 80439 [details] [review] Working patch I tested this out and it fixes the problem seen in Tomboy.
Comment on attachment 80439 [details] [review] Working patch There's no need to pass an actual GdkEvent to gtk_text_view_end_selection_drag() - it just ignores that argument. You may want to extend the patch to: 1. remove the "event" argument from gtk_text_view_end_selection_drag() 2. Fix its callers. 3. Don't create an event in your gkt_text_view_focus_out_event() and don't pass it later.
The assertion in start_selection_drag has meanwhile been removed...
Created attachment 80522 [details] [review] Reworked patch to address issues in comment #6
Matthias, any possibility of getting this committed today and rolling a newer release for GNOME 2.18.0 Beta 1 (GNOME 2.17.90)?
too late for 2.10.9 thats already on the way out, but i'll aim for 2.10.10
2007-03-09 Matthias Clasen <mclasen@redhat.com> * gtk/gtktextview.c (gtk_text_view_end_selection_drag): Get rid of the unused event argument. Update all callers. * gtk/gtktextview.c (gtk_text_view_focus_out): Call gtk_text_view_end_selection_drag. (#351671, Boyd Timothy)
*** Bug 417107 has been marked as a duplicate of this bug. ***
*** Bug 344800 has been marked as a duplicate of this bug. ***
*** Bug 376779 has been marked as a duplicate of this bug. ***
*** Bug 404427 has been marked as a duplicate of this bug. ***