diff options
| author | Krzysztof Kosi??ski <tweenk.pl@gmail.com> | 2010-11-25 20:21:40 +0000 |
|---|---|---|
| committer | Krzysztof KosiĆski <tweenk.pl@gmail.com> | 2010-11-25 20:21:40 +0000 |
| commit | 01e735632a83f127d6fb63067abc50f637867652 (patch) | |
| tree | 3a0178ec722964d0223ba31c05158935dd4d0eb9 /src/sp-pattern.cpp | |
| parent | Fix drag & drop from swatches - patch by Adonis Papaderos (diff) | |
| parent | fix Bug #674109 - Pattern spam when adjusting a pattern in text (diff) | |
| download | inkscape-01e735632a83f127d6fb63067abc50f637867652.tar.gz inkscape-01e735632a83f127d6fb63067abc50f637867652.zip | |
Fix ef spam when adjusting pattern on text - patch from Adonis Papaderos
Fixed bugs:
- https://launchpad.net/bugs/674109
(bzr r9920)
Diffstat (limited to 'src/sp-pattern.cpp')
| -rw-r--r-- | src/sp-pattern.cpp | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index ec0d0d576..a2fc9a6b2 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -435,10 +435,40 @@ pattern_ref_modified (SPObject */*ref*/, guint /*flags*/, SPPattern *pattern) /* Conditional to avoid causing infinite loop if there's a cycle in the href chain. */ } + +/** +Count how many times pat is used by the styles of o and its descendants +*/ guint -pattern_users (SPPattern *pattern) +count_pattern_hrefs(SPObject *o, SPPattern *pat) { - return SP_OBJECT (pattern)->hrefcount; + if (!o) + return 1; + + guint i = 0; + + SPStyle *style = SP_OBJECT_STYLE(o); + if (style + && style->fill.isPaintserver() + && SP_IS_PATTERN(SP_STYLE_FILL_SERVER(style)) + && SP_PATTERN(SP_STYLE_FILL_SERVER(style)) == pat) + { + i ++; + } + if (style + && style->stroke.isPaintserver() + && SP_IS_PATTERN(SP_STYLE_STROKE_SERVER(style)) + && SP_PATTERN(SP_STYLE_STROKE_SERVER(style)) == pat) + { + i ++; + } + + for (SPObject *child = sp_object_first_child(o); + child != NULL; child = SP_OBJECT_NEXT(child)) { + i += count_pattern_hrefs(child, pat); + } + + return i; } SPPattern * @@ -465,7 +495,7 @@ pattern_chain (SPPattern *pattern) SPPattern * sp_pattern_clone_if_necessary (SPItem *item, SPPattern *pattern, const gchar *property) { - if (pattern_users(pattern) > 1) { + if (!pattern->href || SP_OBJECT_HREFCOUNT(pattern) > count_pattern_hrefs(item, pattern)) { pattern = pattern_chain (pattern); gchar *href = g_strconcat ("url(#", SP_OBJECT_REPR (pattern)->attribute("id"), ")", NULL); |
