Code

Fix crash
authorJon A. Cruz <jon@joncruz.org>
Sun, 21 Mar 2010 22:16:39 +0000 (15:16 -0700)
committerJon A. Cruz <jon@joncruz.org>
Sun, 21 Mar 2010 22:16:39 +0000 (15:16 -0700)
src/widgets/paint-selector.cpp
src/widgets/swatch-selector.cpp
src/widgets/swatch-selector.h

index 892793543fe59952bbdefedc9ef3307d559ea12f..3eaec1c231904f1435586e2e3bfc330f13665ef2 100644 (file)
@@ -125,9 +125,15 @@ static bool isPaintModeGradient( SPPaintSelectorMode mode )
 
 static SPGradientSelector *getGradientFromData(SPPaintSelector *psel)
 {
-    // TODO g_message("FIXME FIXME");
-    gchar const* key = (psel->mode == SP_PAINT_SELECTOR_MODE_SWATCH) ? "swatch-selector" : "gradient-selector";
-    SPGradientSelector *grad = reinterpret_cast<SPGradientSelector*>(gtk_object_get_data(GTK_OBJECT(psel->selector), key));
+    SPGradientSelector *grad = 0;
+    if (psel->mode == SP_PAINT_SELECTOR_MODE_SWATCH) {
+        SwatchSelector *swatchsel = static_cast<SwatchSelector*>(g_object_get_data(G_OBJECT(psel->selector), "swatch-selector"));
+        if (swatchsel) {
+            grad = swatchsel->getGradientSelector();
+        }
+    } else {
+        grad = reinterpret_cast<SPGradientSelector*>(gtk_object_get_data(GTK_OBJECT(psel->selector), "gradient-selector"));
+    }
     return grad;
 }
 
index a7bd5eae1126d816b081c0b67a5a0afc5d437527..50ee632cd1e5af7b5fd695397d5a86db608cb934 100644 (file)
@@ -57,6 +57,11 @@ SwatchSelector::~SwatchSelector()
     _gsel = 0;
 }
 
+SPGradientSelector *SwatchSelector::getGradientSelector()
+{
+    return _gsel;
+}
+
 void SwatchSelector::_grabbedCb(SPColorSelector * /*csel*/, void * /*data*/)
 {
 }
index cf1c24da1d450e147a643829a0be5bfa75f6fe7a..83acf9fdac4f9dac5a6e8e2d61301aed886f5b91 100644 (file)
@@ -28,6 +28,8 @@ public:
 
     void setVector(SPDocument *doc, SPGradient *vector);
 
+    SPGradientSelector *getGradientSelector();
+
 private:
     static void _grabbedCb(SPColorSelector *csel, void *data);
     static void _draggedCb(SPColorSelector *csel, void *data);