diff options
| author | Krzysztof Kosi??ski <tweenk.pl@gmail.com> | 2010-08-12 22:13:20 +0000 |
|---|---|---|
| committer | Krzysztof KosiĆski <tweenk.pl@gmail.com> | 2010-08-12 22:13:20 +0000 |
| commit | 67a9706d3aff71597ac1d6d72e329b1a88d1d70e (patch) | |
| tree | 47121f7fe9a3d52a961d35dd832296d6d47968b4 /src/sp-pattern.cpp | |
| parent | Do not un-premultiply alpha when computing mask luminance (diff) | |
| download | inkscape-67a9706d3aff71597ac1d6d72e329b1a88d1d70e.tar.gz inkscape-67a9706d3aff71597ac1d6d72e329b1a88d1d70e.zip | |
Fix crash on empty patterns
(bzr r9508.1.62)
Diffstat (limited to 'src/sp-pattern.cpp')
| -rw-r--r-- | src/sp-pattern.cpp | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 8d156bc77..e211203d4 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -588,6 +588,35 @@ sp_pattern_create_pattern(SPPaintServer *ps, if (!visible) return NULL; + /* Show items */ + SPPattern *shown = NULL; + for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { + // find the first one with item children + if (pat_i && SP_IS_OBJECT (pat_i) && pattern_hasItemChildren(pat_i)) { + shown = pat_i; + break; // do not go further up the chain if children are found + } + } + + if (!shown) { + return cairo_pattern_create_rgba(0,0,0,0); + } + + /* Create arena */ + NRArena *arena = NRArena::create(); + unsigned int dkey = sp_item_display_key_new (1); + NRArenaGroup *root = NRArenaGroup::create(arena); + + for (SPObject *child = sp_object_first_child(SP_OBJECT(shown)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { + if (SP_IS_ITEM (child)) { + // for each item in pattern, show it on our arena, add to the group, + // and connect to the release signal in case the item gets deleted + NRArenaItem *cai; + cai = sp_item_invoke_show (SP_ITEM (child), arena, dkey, SP_ITEM_SHOW_DISPLAY); + nr_arena_item_append_child (root, cai); + } + } + if (pat->viewBox_set) { gdouble tmp_x = pattern_width (pat) / (pattern_viewBox(pat)->x1 - pattern_viewBox(pat)->x0); gdouble tmp_y = pattern_height (pat) / (pattern_viewBox(pat)->y1 - pattern_viewBox(pat)->y0); @@ -604,30 +633,6 @@ sp_pattern_create_pattern(SPPaintServer *ps, } ps2user = Geom::Translate (pattern_x (pat), pattern_y (pat)) * ps2user; - /* Create arena */ - NRArena *arena = NRArena::create(); - unsigned int dkey = sp_item_display_key_new (1); - NRArenaGroup *root = NRArenaGroup::create(arena); - - /* Show items */ - SPPattern *shown = NULL; - for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { - // find the first one with item children - if (pat_i && SP_IS_OBJECT (pat_i) && pattern_hasItemChildren(pat_i)) { - shown = pat_i; - for (SPObject *child = sp_object_first_child(SP_OBJECT(pat_i)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { - if (SP_IS_ITEM (child)) { - // for each item in pattern, show it on our arena, add to the group, - // and connect to the release signal in case the item gets deleted - NRArenaItem *cai; - cai = sp_item_invoke_show (SP_ITEM (child), arena, dkey, SP_ITEM_SHOW_DISPLAY); - nr_arena_item_append_child (root, cai); - } - } - break; // do not go further up the chain if children are found - } - } - double x = pattern_x(pat); double y = pattern_y(pat); double w = pattern_width(pat); |
