From: scislac Date: Tue, 22 Sep 2009 05:16:43 +0000 (+0000) Subject: Fix by Adib for 430804. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=ea7414b9c57c6f6dfce65f253a34d1c617cdcf40;p=inkscape.git Fix by Adib for 430804. --- diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index af432bdf3..3ca2b0dba 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -52,7 +52,7 @@ #if defined (SOLARIS) && (SOLARIS == 8) #include "round.h" using Inkscape::round; -#endif +#endif namespace Inkscape { namespace Filters { @@ -92,9 +92,9 @@ Filter::Filter() Filter::Filter(int n) { _primitive_count = 0; - _primitive_table_size = n; - _primitive = new FilterPrimitive*[n]; - for ( int i = 0 ; i < n ; i++ ) { + _primitive_table_size = (n > 0) ? n : 1; // we guarantee there is at least 1(one) filter slot + _primitive = new FilterPrimitive*[_primitive_table_size]; + for ( int i = 0 ; i < _primitive_table_size ; i++ ) { _primitive[i] = NULL; } _common_init(); @@ -159,7 +159,7 @@ int Filter::render(NRArenaItem const *item, NRPixBlock *pb) // It's no use to try and filter an empty object. return 1; } - + FilterUnits units(_filter_units, _primitive_units); units.set_ctm(trans); units.set_item_bbox(item_bbox); @@ -370,7 +370,11 @@ void Filter::_enlarge_primitive_table() { for (int i = _primitive_count ; i < _primitive_table_size ; i++) { new_tbl[i] = NULL; } - delete[] _primitive; + if(_primitive != NULL) { + delete[] _primitive; + } else { + g_warning("oh oh"); + } _primitive = new_tbl; } @@ -434,7 +438,7 @@ void Filter::clear_primitives() } void Filter::set_x(SVGLength const &length) -{ +{ if (length._set) _region_x = length; } @@ -449,7 +453,7 @@ void Filter::set_width(SVGLength const &length) _region_width = length; } void Filter::set_height(SVGLength const &length) -{ +{ if (length._set) _region_height = length; } diff --git a/src/extension/internal/filter/filter.cpp b/src/extension/internal/filter/filter.cpp index 048207332..d98f8e9a2 100644 --- a/src/extension/internal/filter/filter.cpp +++ b/src/extension/internal/filter/filter.cpp @@ -70,7 +70,7 @@ Filter::get_filter (Inkscape::Extension::Extension * ext) { return sp_repr_read_mem(filter, strlen(filter), NULL); } -void +void Filter::merge_filters (Inkscape::XML::Node * to, Inkscape::XML::Node * from, Inkscape::XML::Document * doc, gchar * srcGraphic, gchar * srcGraphicAlpha) { if (from == NULL) return; @@ -99,7 +99,7 @@ Filter::merge_filters (Inkscape::XML::Node * to, Inkscape::XML::Node * from, Ink from_child != NULL ; from_child = from_child->next()) { Glib::ustring name = "svg:"; name += from_child->name(); - + Inkscape::XML::Node * to_child = doc->createElement(name.c_str()); to->appendChild(to_child); merge_filters(to_child, from_child, doc, srcGraphic, srcGraphicAlpha); @@ -149,7 +149,7 @@ Filter::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *d Glib::ustring url = "url(#"; url += newfilterroot->attribute("id"); url += ")"; merge_filters(newfilterroot, filterdoc->root(), xmldoc); - + Inkscape::GC::release(newfilterroot); sp_repr_css_set_property(css, "filter", url.c_str()); @@ -170,21 +170,29 @@ Filter::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *d } g_free(lfilter); + // no filter if (filternode == NULL) { + g_warning("no assoziating filter found!"); continue; } - filternode->lastChild()->setAttribute("result", FILTER_SRC_GRAPHIC); + if (filternode->lastChild() == NULL) { + // empty filter, we insert + merge_filters(filternode, filterdoc->root(), xmldoc); + } else { + // existing filter, we merge + filternode->lastChild()->setAttribute("result", FILTER_SRC_GRAPHIC); + Inkscape::XML::Node * alpha = xmldoc->createElement("svg:feColorMatrix"); + alpha->setAttribute("result", FILTER_SRC_GRAPHIC_ALPHA); + alpha->setAttribute("in", FILTER_SRC_GRAPHIC); // not required, but we're being explicit + alpha->setAttribute("values", "0 0 0 -1 0 0 0 0 -1 0 0 0 0 -1 0 0 0 0 1 0"); - Inkscape::XML::Node * alpha = xmldoc->createElement("svg:feColorMatrix"); - alpha->setAttribute("result", FILTER_SRC_GRAPHIC_ALPHA); - alpha->setAttribute("in", FILTER_SRC_GRAPHIC); // not required, but we're being explicit - alpha->setAttribute("values", "0 0 0 -1 0 0 0 0 -1 0 0 0 0 -1 0 0 0 0 1 0"); - filternode->appendChild(alpha); + filternode->appendChild(alpha); - merge_filters(filternode, filterdoc->root(), xmldoc, FILTER_SRC_GRAPHIC, FILTER_SRC_GRAPHIC_ALPHA); + merge_filters(filternode, filterdoc->root(), xmldoc, FILTER_SRC_GRAPHIC, FILTER_SRC_GRAPHIC_ALPHA); - Inkscape::GC::release(alpha); + Inkscape::GC::release(alpha); + } } }