Crash in gtk_grab_notify



Hi all,


I have an "endless" loop, until I get a crash due to a stack overflow, with grab notifications. Here is a complete test case:


#include <gtk/gtk.h>

gboolean
on_button_pressed (GtkWidget *widget,
                   GdkEvent  *event,
                   gpointer   user_data)
{
        if ((event->type == GDK_BUTTON_PRESS) &&
         (((GdkEventButton *) event)->button == 3))
        {
                gtk_menu_popup (GTK_MENU (user_data),
                                NULL, NULL, NULL, NULL,
                                ((GdkEventButton *)event)->button,
                                ((GdkEventButton *)event)->time);

                return TRUE;
        }

        return FALSE;
}

int
main (int argc, char *argv[])
{
        GtkWidget *window;
        GtkWidget *box;
        GtkWidget *view;
        GtkWidget *scrollbar;
        GtkWidget *menu;
        
        gtk_init (&argc, &argv);

        view = gtk_tool_palette_new ();
        scrollbar = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL,
                gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (view)));
        box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
        gtk_box_pack_start (GTK_BOX (box), view, TRUE, TRUE, 0);
        gtk_box_pack_start (GTK_BOX (box), scrollbar, FALSE, FALSE, 0);

        menu = gtk_menu_new ();
        g_signal_connect (G_OBJECT (box),
                         "button-press-event",
                         G_CALLBACK (on_button_pressed),
                         menu);
        
        window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
        gtk_container_add (GTK_CONTAINER (window), box);
        
        g_signal_connect (window,
                         "destroy",
                         G_CALLBACK (gtk_main_quit), NULL);
        
        gtk_widget_show_all (window);

        gtk_main ();

        return 0;
}

This program displays a (empty) menu when the user clicks with the right button on a widget composed by a GtkToolPalette (this widget doesn't really matter) and a GtkScrollBar.

The crash happens when the user first clicks on the scrollbar with the left mouse button then presses the right mouse button, without releasing the left mouse button.

The first click grabs the slider of the scrollbar, while the second one releases the first grab and adds a new grab for the menu but the scrollbar receives continuously grab notifications.


Is there something wrong in my test case?


There is a stack trace in the bug reported in Anjuta here:
https://bugzilla.gnome.org/show_bug.cgi?id=671684


Regards,

Sébastien



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]