After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 351671 - textview should stop selecting when losing focus
textview should stop selecting when losing focus
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkTextView
unspecified
Other All
: Normal critical
: ---
Assigned To: gtk-bugs
gtk-bugs
: 344800 376779 404427 417107 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2006-08-16 20:37 UTC by Boyd Timothy
Modified: 2007-06-07 03:48 UTC
See Also:
GNOME target: ---
GNOME version: 2.11/2.12


Attachments
Working patch (624 bytes, patch)
2007-01-16 23:44 UTC, Boyd Timothy
needs-work Details | Review
Reworked patch to address issues in comment #6 (2.55 KB, patch)
2007-01-17 16:30 UTC, Boyd Timothy
none Details | Review

Description Boyd Timothy 2006-08-16 20:37:32 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!
Comment 1 Alex Graveley 2006-08-16 21:35:16 UTC
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.
Comment 2 Boyd Timothy 2007-01-13 01:01:14 UTC
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.
Comment 3 Boyd Timothy 2007-01-16 22:58:09 UTC
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 ().
Comment 4 Boyd Timothy 2007-01-16 23:43:33 UTC
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.
Comment 5 Boyd Timothy 2007-01-16 23:44:54 UTC
Created attachment 80439 [details] [review]
Working patch

I tested this out and it fixes the problem seen in Tomboy.
Comment 6 Federico Mena Quintero 2007-01-17 00:36:58 UTC
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.
Comment 7 Matthias Clasen 2007-01-17 03:09:45 UTC
The assertion in start_selection_drag has meanwhile been removed...
Comment 8 Boyd Timothy 2007-01-17 16:30:48 UTC
Created attachment 80522 [details] [review]
Reworked patch to address issues in comment #6
Comment 9 Boyd Timothy 2007-01-22 17:33:29 UTC
Matthias, any possibility of getting this committed today and rolling a newer release for GNOME 2.18.0 Beta 1 (GNOME 2.17.90)?
Comment 10 Matthias Clasen 2007-01-22 17:37:26 UTC
too late for 2.10.9 thats already on the way out, but i'll aim for 2.10.10
Comment 11 Matthias Clasen 2007-03-10 03:56:21 UTC
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)

Comment 12 Boyd Timothy 2007-03-11 19:01:31 UTC
*** Bug 417107 has been marked as a duplicate of this bug. ***
Comment 13 Yevgen Muntyan 2007-06-07 03:46:00 UTC
*** Bug 344800 has been marked as a duplicate of this bug. ***
Comment 14 Yevgen Muntyan 2007-06-07 03:46:16 UTC
*** Bug 376779 has been marked as a duplicate of this bug. ***
Comment 15 Yevgen Muntyan 2007-06-07 03:48:06 UTC
*** Bug 404427 has been marked as a duplicate of this bug. ***