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 733766 - W32: gedit crashes when closing a print dialogue
W32: gedit crashes when closing a print dialogue
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: Win32
unspecified
Other All
: Normal normal
: ---
Assigned To: gtk-win32 maintainers
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2014-07-25 23:38 UTC by LRN
Modified: 2014-08-02 14:18 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
W32: Don't unregister parent window of an embedded widget (1.14 KB, patch)
2014-07-25 23:38 UTC, LRN
committed Details | Review
Use g_clear_object() shorthand for unref-and-set-to-null (1.03 KB, patch)
2014-08-02 05:17 UTC, LRN
committed Details | Review

Description LRN 2014-07-25 23:38:29 UTC
Gtk:ERROR:gtkwidget.c:15836:gtk_widget_unregister_window: assertion failed: (user_data == widget)
Comment 1 LRN 2014-07-25 23:38:33 UTC
Created attachment 281738 [details] [review]
W32: Don't unregister parent window of an embedded widget

This leads to an assertion failure, because parent window is never registered
in the first place, widget's own GdkWindow is. But that window is unregistered
in a generic fashion by GtkWidget code, so there's nothing for us to do here.
Comment 3 Ignacio Casal Quinteiro (nacho) 2014-07-28 07:54:39 UTC
Review of attachment 281738 [details] [review]:

This is weird, is there a possiblitiy whether could reach here with a registered window?
Comment 4 LRN 2014-07-28 08:28:57 UTC
I don't know. I just observed that there's only one call to gtk_widget_register_window() in gtkwin32embedwidget.c, and that call registers the widget window itself, not its parent. Which means that unregistering parent later on makes no sense.

Alex probably knows for sure, since it's his code.

I've looked at how other widgets use this API. Here's what i think:

static void
gtk_revealer_real_realize (GtkWidget *widget)
{
...

  /* Create GdkWindow */
  priv->view_window =
    gdk_window_new (gtk_widget_get_parent_window ((GtkWidget*) revealer),
                    &attributes, attributes_mask);
  /* Make it THE window of the widget */
  gtk_widget_set_window (widget, priv->view_window);
  /* Register it */
  gtk_widget_register_window (widget, priv->view_window);

...

  /* Create another GdkWindow */
  priv->bin_window =
    gdk_window_new (priv->view_window, &attributes, attributes_mask);
  /* Register it */
  gtk_widget_register_window (widget, priv->bin_window);

...
}

static void
gtk_revealer_real_unrealize (GtkWidget *widget)
{
  GtkRevealer *revealer = GTK_REVEALER (widget);
  GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer);

  /* unregister the bin window*/
  gtk_widget_unregister_window (widget, priv->bin_window);
  gdk_window_destroy (priv->bin_window);
  priv->view_window = NULL;

  /* Presumably, widget's own window (view_window) is unregistered
   * somewhere down here. That is, i know that it's unregistered somewhere
   * in GtkWidget (i've seen it in gdb at a breakpoint), but i don't remember
   * how that place is reached. But it's likely through this call.
   */
  GTK_WIDGET_CLASS (gtk_revealer_parent_class)->unrealize (widget);
}


That is, widget's own GdkWindow needs to be registered, but does not require deregistration.
Extra GdkWindows of the widget also need to be registered, but, unlike the main window, they don't have generic unreg code, and thus need to be unregistered manually.
Comment 5 Paolo Borelli 2014-08-01 20:16:42 UTC
Review of attachment 281738 [details] [review]:

the patch looks correct to me: for sure the window that is unregistering is not the same that it is registering, so that definitely looks like a bug.

beside if you look for instance at gtkoffscreenwindow.c, it does the same thing and does not unregister
Comment 6 Paolo Borelli 2014-08-01 20:23:04 UTC
while changing those line you can clean things up using g_clear_object instead of the whole if block
Comment 7 LRN 2014-08-02 05:17:10 UTC
Created attachment 282310 [details] [review]
Use g_clear_object() shorthand for unref-and-set-to-null
Comment 8 Paolo Borelli 2014-08-02 14:18:01 UTC
Review of attachment 282310 [details] [review]:

let's get this in. in any case it is better than crashing
Comment 9 LRN 2014-08-02 14:18:42 UTC
Attachment 281738 [details] pushed as e1acb93 - W32: Don't unregister parent window of an embedded widget
Attachment 282310 [details] pushed as bbe475f - Use g_clear_object() shorthand for unref-and-set-to-null