Index: gtkscalebutton.c
===================================================================
--- gtkscalebutton.c	(revision 18880)
+++ gtkscalebutton.c	(working copy)
@@ -872,6 +872,8 @@
   GdkDisplay *display;
   GtkScaleButtonPrivate *priv;
 
+  g_message ("gtk_scale_button_grab_notify");
+
   if (was_grabbed != FALSE)
     return;
 
@@ -880,6 +882,11 @@
   if (gtk_widget_is_ancestor (gtk_grab_get_current (), priv->dock))
     return;
 
+  /* Check whether we have the grab for this dock before releasing
+   * the keyboard and mouse grabs */
+  if (!GTK_WIDGET_HAS_GRAB (priv->dock))
+    return;
+
   display = gtk_widget_get_display (priv->dock);
   gdk_display_keyboard_ungrab (display, GDK_CURRENT_TIME);
   gdk_display_pointer_ungrab (display, GDK_CURRENT_TIME);
