Code

workaround for crash 1580903 and several other issues caused by GTK's braindead behav...
authorbuliabyak <buliabyak@users.sourceforge.net>
Thu, 26 Oct 2006 06:58:34 +0000 (06:58 +0000)
committerbuliabyak <buliabyak@users.sourceforge.net>
Thu, 26 Oct 2006 06:58:34 +0000 (06:58 +0000)
src/dialogs/fill-style.cpp
src/dialogs/object-properties.cpp
src/ui/widget/selected-style.cpp

index 22c1ee0f70dfaf0a7caf74d823cb6fb863fa4921..9933887f31f6e7f9d0e045e308c2339c6514ded6 100644 (file)
@@ -35,6 +35,7 @@
 #include <document-private.h>
 #include <xml/repr.h>
 #include <glibmm/i18n.h>
+#include <display/sp-canvas.h>
 
 
 // These can be deleted once we sort out the libart dependence.
@@ -396,9 +397,14 @@ sp_fill_style_widget_paint_changed ( SPPaintSelector *psel,
         case SP_PAINT_SELECTOR_MODE_COLOR_RGB:
         case SP_PAINT_SELECTOR_MODE_COLOR_CMYK:
         {
+            // FIXME: fix for GTK breakage, see comment in SelectedStyle::on_opacity_changed; here it results in losing release events
+            sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(desktop), 0);
+
             sp_paint_selector_set_flat_color (psel, desktop, "fill", "fill-opacity");
             sp_document_maybe_done (sp_desktop_document(desktop), undo_label, SP_VERB_DIALOG_FILL_STROKE,
                                     _("Set fill color"));
+            // resume interruptibility
+            sp_canvas_end_forced_full_redraws(sp_desktop_canvas(desktop));
 
             // on release, toggle undo_label so that the next drag will not be lumped with this one
             if (undo_label == undo_label_1)
index 77d71b5fe5839f100bd4d61a0962138fbf0b4bc9..dc04d27727d769f43b8a6649b455407cd23dee39 100644 (file)
@@ -44,6 +44,7 @@
 #include "document-private.h"
 #include <selection.h>
 #include "xml/repr.h"
+#include "display/sp-canvas.h"
 
 static GtkWidget *dlg = NULL;
 static win_data wd;
@@ -360,6 +361,9 @@ sp_fillstroke_opacity_changed (GtkAdjustment *a, SPWidget *base)
 
     gtk_object_set_data (GTK_OBJECT (dlg), "blocked", GUINT_TO_POINTER (TRUE));
 
+    // FIXME: fix for GTK breakage, see comment in SelectedStyle::on_opacity_changed; here it results in crash 1580903
+    sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(SP_ACTIVE_DESKTOP), 0);
+
     SPCSSAttr *css = sp_repr_css_attr_new ();
 
     Inkscape::CSSOStringStream os;
@@ -373,6 +377,9 @@ sp_fillstroke_opacity_changed (GtkAdjustment *a, SPWidget *base)
     sp_document_maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "fillstroke:opacity", SP_VERB_DIALOG_FILL_STROKE, 
                             _("Change opacity"));
 
+    // resume interruptibility
+    sp_canvas_end_forced_full_redraws(sp_desktop_canvas(SP_ACTIVE_DESKTOP));
+
     gtk_object_set_data (GTK_OBJECT (dlg), "blocked", GUINT_TO_POINTER (FALSE));
 }
 
@@ -386,12 +393,15 @@ sp_fillstroke_blur_changed (GtkAdjustment *a, SPWidget *base)
 
      //lock dialog
     gtk_object_set_data (GTK_OBJECT (dlg), "blocked", GUINT_TO_POINTER (TRUE));
-    
+  
     //get desktop
     SPDesktop *desktop = SP_ACTIVE_DESKTOP;
     if (!desktop) {
         return;
     }
+
+    // FIXME: fix for GTK breakage, see comment in SelectedStyle::on_opacity_changed; here it results in crash 1580903
+    sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(desktop), 0);
     
     //get current selection
     Inkscape::Selection *selection = sp_desktop_selection (desktop);
@@ -423,6 +433,10 @@ sp_fillstroke_blur_changed (GtkAdjustment *a, SPWidget *base)
     }
 
     sp_document_maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "fillstroke:blur", SP_VERB_DIALOG_FILL_STROKE,  _("Change blur"));
+
+    // resume interruptibility
+    sp_canvas_end_forced_full_redraws(sp_desktop_canvas(desktop));
+
     gtk_object_set_data (GTK_OBJECT (dlg), "blocked", GUINT_TO_POINTER (FALSE));
 }
 
index 90efd2da5741259e7aeb5451eec10ecdf7a8b80a..20398ecd9f1d749eb3edb44e0cfe8ec7c3183d89 100644 (file)
@@ -36,6 +36,7 @@
 #include "svg/css-ostringstream.h"
 #include "helper/units.h"
 #include "verbs.h"
+#include <display/sp-canvas.h>
 
 static gdouble const _sw_presets[]     = { 32 ,  16 ,  10 ,  8 ,  6 ,  4 ,  3 ,  2 ,  1.5 ,  1 ,  0.75 ,  0.5 ,  0.25 ,  0.1 };
 static gchar* const _sw_presets_str[] = {"32", "16", "10", "8", "6", "4", "3", "2", "1.5", "1", "0.75", "0.5", "0.25", "0.1"};
@@ -973,6 +974,7 @@ SelectedStyle::update()
     case QUERY_STYLE_MULTIPLE_AVERAGED:
     case QUERY_STYLE_MULTIPLE_SAME:
         _tooltips.set_tip(_opacity_place, _("Master opacity"));
+        if (_opacity_blocked) break;
         _opacity_blocked = true;
         _opacity_sb.set_sensitive(true);
         _opacity_adjustment.set_value(SP_SCALE24_TO_FLOAT(query->opacity.value));
@@ -1074,10 +1076,20 @@ void SelectedStyle::on_opacity_changed () {
     Inkscape::CSSOStringStream os;
     os << CLAMP (_opacity_adjustment.get_value(), 0.0, 1.0);
     sp_repr_css_set_property (css, "opacity", os.str().c_str());
+    // FIXME: workaround for GTK breakage: display interruptibility sometimes results in GTK
+    // sending multiple value-changed events. As if when Inkscape interrupts redraw for main loop
+    // iterations, GTK discovers that this callback hasn't finished yet, and for some weird reason
+    // decides to add yet another value-changed event to the queue. Totally braindead if you ask
+    // me. As a result, scrolling the spinbutton once results in runaway change until it hits 1.0
+    // or 0.0. (And no, this is not a race with ::update, I checked that.)
+    // Sigh. So we disable interruptibility while we're setting the new value.
+    sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(_desktop), 0);
     sp_desktop_set_style (_desktop, css);
     sp_repr_css_attr_unref (css);
     sp_document_maybe_done (sp_desktop_document (_desktop), "fillstroke:opacity", SP_VERB_DIALOG_FILL_STROKE,
                       _("Change opacity"));
+    // resume interruptibility
+    sp_canvas_end_forced_full_redraws(sp_desktop_canvas(_desktop));
     spinbutton_defocus(GTK_OBJECT(_opacity_sb.gobj()));
     _opacity_blocked = false;
 }