~valavanisalex/ubuntu/oneiric/inkscape/inkscape_0.48.1-2.1ubuntu1

« back to all changes in this revision

Viewing changes to debian/patches/102_sp_pattern_painter_free.dpatch

  • Committer: Bazaar Package Importer
  • Author(s): Bryce Harrington
  • Date: 2009-04-08 00:35:13 UTC
  • Revision ID: james.westby@ubuntu.com-20090408003513-u90sqtbl891tftmb
Tags: 0.46-5ubuntu3
* Add 102_sp_pattern_painter_free.dpatch: Fix SIGSEGV in
  sp_pattern_painter_free that occurs when drawing gears and creating 3d
  boxes.
  (LP: #198608)
* Add 103_bitmap_type_print.dpatch: Bitmap-type print to printer and
  preview produces low resolution output.
  (LP: #258916)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh /usr/share/dpatch/dpatch-run
 
2
## 102_sp_pattern_painter_free.dpatch by Bryce Harrington <bryce@ubuntu.com>
 
3
##
 
4
## All lines beginning with `## DP:' are a description of the patch.
 
5
## DP: Fix SIGSEGV in sp_pattern_painter_free that can be reproduced
 
6
## DP: as follows:
 
7
## DP:
 
8
## DP:   o run inkscape
 
9
## DP:   o render a gear with default settings
 
10
## DP:   o try to create a 3d box
 
11
## DP:   o segfault
 
12
## DP: https://bugs.edge.launchpad.net/ubuntu/+source/inkscape/+bug/198608
 
13
 
 
14
@DPATCH@
 
15
 
 
16
diff -Nurp patched/src/sp-pattern.cpp working/src/sp-pattern.cpp
 
17
--- patched/src/sp-pattern.cpp  2009-04-07 22:48:39.000000000 -0700
 
18
+++ working/src/sp-pattern.cpp  2009-04-07 22:51:16.000000000 -0700
 
19
@@ -57,6 +57,8 @@ struct SPPatPainter {
 
20
        NRMatrix     pa2ca;
 
21
        NRRectL      cached_bbox;
 
22
        NRPixBlock   cached_tile;
 
23
+
 
24
+  std::map<SPObject *, sigc::connection> *_release_connections;
 
25
 };
 
26
 
 
27
 static void sp_pattern_class_init (SPPatternClass *klass);
 
28
@@ -632,6 +634,19 @@ bool pattern_hasItemChildren (SPPattern 
 
29
 
 
30
 static void sp_pat_fill (SPPainter *painter, NRPixBlock *pb);
 
31
 
 
32
+// item in this pattern is about to be deleted, hide it on our arena and disconnect
 
33
+void
 
34
+sp_pattern_painter_release (SPObject *obj, SPPatPainter *painter)
 
35
+{
 
36
+       std::map<SPObject *, sigc::connection>::iterator iter = painter->_release_connections->find(obj);
 
37
+       if (iter != painter->_release_connections->end()) {
 
38
+               iter->second.disconnect();
 
39
+    painter->_release_connections->erase(obj);
 
40
+       }
 
41
+
 
42
+       sp_item_invoke_hide(SP_ITEM(obj), painter->dkey);
 
43
+}
 
44
+
 
45
 /**
 
46
 Creates a painter (i.e. the thing that does actual filling at the given zoom).
 
47
 See (*) below for why the parent_transform may be necessary.
 
48
@@ -728,7 +743,8 @@ sp_pattern_painter_new (SPPaintServer *p
 
49
        pp->root = NRArenaGroup::create(pp->arena);
 
50
 
 
51
        /* Show items */
 
52
-       for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) {
 
53
+       pp->_release_connections = new std::map<SPObject *, sigc::connection>;
 
54
+        for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) {
 
55
                if (pat_i && SP_IS_OBJECT (pat_i) && pattern_hasItemChildren(pat_i)) { // find the first one with item children
 
56
                        for (SPObject *child = sp_object_first_child(SP_OBJECT(pat_i)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
 
57
                                if (SP_IS_ITEM (child)) {
 
58
@@ -736,6 +752,7 @@ sp_pattern_painter_new (SPPaintServer *p
 
59
                                        cai = sp_item_invoke_show (SP_ITEM (child), pp->arena, pp->dkey, SP_ITEM_REFERENCE_FLAGS);
 
60
                                        nr_arena_item_append_child (pp->root, cai);
 
61
                                        nr_arena_item_unref (cai);
 
62
+                                        pp->_release_connections->insert(std::make_pair(child, child->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_pattern_painter_release), pp))));
 
63
                                }
 
64
                        }
 
65
                        break; // do not go further up the chain if children are found
 
66
@@ -797,22 +814,25 @@ sp_pattern_painter_new (SPPaintServer *p
 
67
        return (SPPainter *) pp;
 
68
 }
 
69
 
 
70
+
 
71
 static void
 
72
 sp_pattern_painter_free (SPPaintServer */*ps*/, SPPainter *painter)
 
73
 {
 
74
        SPPatPainter *pp = (SPPatPainter *) painter;
 
75
-       SPPattern *pat = pp->pat;
 
76
-
 
77
-       for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) {
 
78
-               if (pat_i && SP_IS_OBJECT (pat_i) && pattern_hasItemChildren(pat_i)) { // find the first one with item children
 
79
-                       for (SPObject *child = sp_object_first_child(SP_OBJECT(pat_i)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
 
80
-                               if (SP_IS_ITEM (child)) {
 
81
-                                               sp_item_invoke_hide (SP_ITEM (child), pp->dkey);
 
82
-                               }
 
83
-                       }
 
84
-                       break; // do not go further up the chain if children are found
 
85
-               }
 
86
+       // free our arena
 
87
+  if (pp->arena) {
 
88
+      ((NRObject *) pp->arena)->unreference();
 
89
+      pp->arena = NULL;
 
90
+  }
 
91
+
 
92
+       // disconnect all connections
 
93
+  std::map<SPObject *, sigc::connection>::iterator iter;
 
94
+  for (iter = pp->_release_connections->begin() ; iter!=pp->_release_connections->end() ; iter++) {
 
95
+         iter->second.disconnect();
 
96
        }
 
97
+       pp->_release_connections->clear();
 
98
+  delete pp->_release_connections;
 
99
+
 
100
        if ( pp->use_cached_tile ) nr_pixblock_release(&pp->cached_tile);
 
101
        g_free (pp);
 
102
 }
 
103
@@ -996,6 +1016,6 @@ sp_pat_fill (SPPainter *painter, NRPixBl
 
104
                                nr_pixblock_release (&ppb);
 
105
                        }
 
106
                }
 
107
-        } 
 
108
+     } 
 
109
        }
 
110
 }