From d0b1841dd74661cc395ee08660a0848a86cd625d Mon Sep 17 00:00:00 2001 From: ishmal Date: Sat, 21 Apr 2007 19:26:31 +0000 Subject: [PATCH] Fix use of uninitialized 'doc' var. Fix use of gc::released 'repr'. --- src/widgets/gradient-selector.cpp | 33 ++++++++++++++++++------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp index 88a04bd7a..0091fb3c9 100644 --- a/src/widgets/gradient-selector.cpp +++ b/src/widgets/gradient-selector.cpp @@ -302,22 +302,23 @@ sp_gradient_selector_edit_vector_clicked (GtkWidget *w, SPGradientSelector *sel) static void sp_gradient_selector_add_vector_clicked (GtkWidget *w, SPGradientSelector *sel) { - SPDocument *doc; - SPGradient *gr; - Inkscape::XML::Node *repr; - Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); + SPDocument *doc = sp_gradient_vector_selector_get_document ( + SP_GRADIENT_VECTOR_SELECTOR (sel->vectors)); - doc = sp_gradient_vector_selector_get_document (SP_GRADIENT_VECTOR_SELECTOR (sel->vectors)); - if (!doc) return; - gr = sp_gradient_vector_selector_get_gradient (SP_GRADIENT_VECTOR_SELECTOR (sel->vectors)); + if (!doc) + return; - if (gr) { + SPGradient *gr = sp_gradient_vector_selector_get_gradient( + SP_GRADIENT_VECTOR_SELECTOR (sel->vectors)); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); + + Inkscape::XML::Node *repr = NULL; + + if (gr) repr = SP_OBJECT_REPR (gr)->duplicate(xml_doc); - } else { - Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); - Inkscape::XML::Node *stop; + else { repr = xml_doc->createElement("svg:linearGradient"); - stop = xml_doc->createElement("svg:stop"); + Inkscape::XML::Node *stop = xml_doc->createElement("svg:stop"); stop->setAttribute("offset", "0"); stop->setAttribute("style", "stop-color:#000;stop-opacity:1;"); repr->appendChild(stop); @@ -330,12 +331,16 @@ sp_gradient_selector_add_vector_clicked (GtkWidget *w, SPGradientSelector *sel) } SP_OBJECT_REPR (SP_DOCUMENT_DEFS (doc))->addChild(repr, NULL); - Inkscape::GC::release(repr); gr = (SPGradient *) doc->getObjectByRepr(repr); - sp_gradient_vector_selector_set_gradient (SP_GRADIENT_VECTOR_SELECTOR (sel->vectors), doc, gr); + sp_gradient_vector_selector_set_gradient( + SP_GRADIENT_VECTOR_SELECTOR (sel->vectors), doc, gr); + + Inkscape::GC::release(repr); } + + static void sp_gradient_selector_spread_activate (GtkWidget *widget, SPGradientSelector *sel) { -- 2.30.2