From 6b6133b74e302813e042e743dd334221b053ae06 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sun, 21 Mar 2010 15:16:39 -0700 Subject: [PATCH] Fix crash --- src/widgets/paint-selector.cpp | 12 +++++++++--- src/widgets/swatch-selector.cpp | 5 +++++ src/widgets/swatch-selector.h | 2 ++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index 892793543..3eaec1c23 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -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(gtk_object_get_data(GTK_OBJECT(psel->selector), key)); + SPGradientSelector *grad = 0; + if (psel->mode == SP_PAINT_SELECTOR_MODE_SWATCH) { + SwatchSelector *swatchsel = static_cast(g_object_get_data(G_OBJECT(psel->selector), "swatch-selector")); + if (swatchsel) { + grad = swatchsel->getGradientSelector(); + } + } else { + grad = reinterpret_cast(gtk_object_get_data(GTK_OBJECT(psel->selector), "gradient-selector")); + } return grad; } diff --git a/src/widgets/swatch-selector.cpp b/src/widgets/swatch-selector.cpp index a7bd5eae1..50ee632cd 100644 --- a/src/widgets/swatch-selector.cpp +++ b/src/widgets/swatch-selector.cpp @@ -57,6 +57,11 @@ SwatchSelector::~SwatchSelector() _gsel = 0; } +SPGradientSelector *SwatchSelector::getGradientSelector() +{ + return _gsel; +} + void SwatchSelector::_grabbedCb(SPColorSelector * /*csel*/, void * /*data*/) { } diff --git a/src/widgets/swatch-selector.h b/src/widgets/swatch-selector.h index cf1c24da1..83acf9fda 100644 --- a/src/widgets/swatch-selector.h +++ b/src/widgets/swatch-selector.h @@ -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); -- 2.30.2