diff options
| author | Markus Engel <markus.engel@tum.de> | 2013-04-01 21:50:52 +0000 |
|---|---|---|
| committer | Markus Engel <markus.engel@tum.de> | 2013-04-01 21:50:52 +0000 |
| commit | 7504b21ce73f7f2d3787ab5f363b5e5acc721a23 (patch) | |
| tree | 9923f639e4c7862b40ffef2e3f21bec5b3be9f23 /src | |
| parent | Replaced calls to g_object_(un)ref with sp_object_(un)ref. (diff) | |
| download | inkscape-7504b21ce73f7f2d3787ab5f363b5e5acc721a23.tar.gz inkscape-7504b21ce73f7f2d3787ab5f363b5e5acc721a23.zip | |
Added experimental constructor to SPRect. Memory leaks because of non-virtual destructor.
(bzr r11608.1.66)
Diffstat (limited to 'src')
| -rw-r--r-- | src/sp-item.cpp | 33 | ||||
| -rw-r--r-- | src/sp-item.h | 5 | ||||
| -rw-r--r-- | src/sp-lpe-item.cpp | 14 | ||||
| -rw-r--r-- | src/sp-lpe-item.h | 1 | ||||
| -rw-r--r-- | src/sp-object.cpp | 24 | ||||
| -rw-r--r-- | src/sp-object.h | 1 | ||||
| -rw-r--r-- | src/sp-rect.cpp | 14 | ||||
| -rw-r--r-- | src/sp-rect.h | 2 | ||||
| -rw-r--r-- | src/sp-shape.cpp | 21 | ||||
| -rw-r--r-- | src/sp-shape.h | 2 |
10 files changed, 88 insertions, 29 deletions
diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 5075bdcd3..63fd25bcc 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -78,7 +78,7 @@ static SPItemView* sp_item_view_list_remove(SPItemView *list, SPItemView *view); -G_DEFINE_TYPE(SPItem, sp_item, SP_TYPE_OBJECT); +G_DEFINE_TYPE(SPItem, sp_item, G_TYPE_OBJECT); /** * SPItem vtable initialization. @@ -96,21 +96,40 @@ CItem::CItem(SPItem* item) : CObject(item) { CItem::~CItem() { } -/** - * Callback for SPItem object initialization. - */ -static void -sp_item_init(SPItem *item) -{ +SPItem::SPItem() : SPObject() { + SPItem* item = this; + item->citem = new CItem(item); item->typeHierarchy.insert(typeid(SPItem)); delete item->cobject; item->cobject = item->citem; + item->sensitive = 0; + item->clip_ref = NULL; + item->avoidRef = NULL; + item->_is_evaluated = false; + item->stop_paint = 0; + item->_evaluated_status = 0; + item->bbox_valid = 0; + item->freeze_stroke_width = false; + item->transform_center_x = 0; + item->transform_center_y = 0; + item->display = NULL; + item->mask_ref = NULL; + item->init(); } +/** + * Callback for SPItem object initialization. + */ +static void +sp_item_init(SPItem *item) +{ + new (item) SPItem(); +} + void SPItem::init() { sensitive = TRUE; bbox_valid = FALSE; diff --git a/src/sp-item.h b/src/sp-item.h index f3002487d..40914dd11 100644 --- a/src/sp-item.h +++ b/src/sp-item.h @@ -27,7 +27,9 @@ #include "snap-preferences.h" #include "snap-candidate.h" -class SPGuideConstraint; +//class SPGuideConstraint; +#include "sp-guide-constraint.h" + class SPClipPathReference; class SPMaskReference; class SPAvoidRef; @@ -119,6 +121,7 @@ public: VISUAL_BBOX }; + SPItem(); CItem* citem; unsigned int sensitive : 1; diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index 5001cb76e..fc75b6a69 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -51,7 +51,7 @@ typedef std::list<std::string> HRefList; static std::string patheffectlist_write_svg(PathEffectList const & list); static std::string hreflist_write_svg(HRefList const & list); -G_DEFINE_TYPE(SPLPEItem, sp_lpe_item, SP_TYPE_ITEM); +G_DEFINE_TYPE(SPLPEItem, sp_lpe_item, G_TYPE_OBJECT); static void sp_lpe_item_class_init(SPLPEItemClass *klass) { @@ -67,9 +67,9 @@ CLPEItem::CLPEItem(SPLPEItem* lpeitem) : CItem(lpeitem) { CLPEItem::~CLPEItem() { } -static void -sp_lpe_item_init(SPLPEItem *lpeitem) -{ +SPLPEItem::SPLPEItem() : SPItem() { + SPLPEItem* lpeitem = this; + lpeitem->clpeitem = new CLPEItem(lpeitem); lpeitem->typeHierarchy.insert(typeid(SPLPEItem)); @@ -85,6 +85,12 @@ sp_lpe_item_init(SPLPEItem *lpeitem) lpeitem->lpe_modified_connection_list = new std::list<sigc::connection>(); } +static void +sp_lpe_item_init(SPLPEItem *lpeitem) +{ + new (lpeitem) SPLPEItem(); +} + static void sp_lpe_item_finalize(GObject *object) { if (((GObjectClass *) (sp_lpe_item_parent_class))->finalize) { diff --git a/src/sp-lpe-item.h b/src/sp-lpe-item.h index 847461116..c10dff0c5 100644 --- a/src/sp-lpe-item.h +++ b/src/sp-lpe-item.h @@ -41,6 +41,7 @@ typedef std::list<Inkscape::LivePathEffect::LPEObjectReference *> PathEffectList class SPLPEItem : public SPItem { public: + SPLPEItem(); CLPEItem* clpeitem; int path_effects_enabled; diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 0ba74990e..66f9b5ab8 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -118,12 +118,9 @@ sp_object_class_init(SPObjectClass *klass) object_class->finalize = sp_object_finalize; } -/** - * Callback to initialize the SPObject object. - */ -static void -sp_object_init(SPObject *object) -{ +SPObject::SPObject() { + SPObject* object = this; + debug("id=%x, typename=%s",object, g_type_name_from_instance((GTypeInstance*)object)); object->cobject = new CObject(object); @@ -131,6 +128,12 @@ sp_object_init(SPObject *object) new (&object->typeHierarchy) std::set<TypeInfo>(); object->typeHierarchy.insert(typeid(SPObject)); + object->repr = NULL; + object->mflags = 0; + object->id = NULL; + object->cloned = 0; + object->uflags = 0; + object->hrefcount = 0; object->_total_hrefcount = 0; object->document = NULL; @@ -160,6 +163,15 @@ sp_object_init(SPObject *object) object->_default_label = NULL; } +/** + * Callback to initialize the SPObject object. + */ +static void +sp_object_init(SPObject *object) +{ + new (object) SPObject(); +} + // CPPIFY: make pure virtual void CObject::read_content() { //throw; diff --git a/src/sp-object.h b/src/sp-object.h index 1b40e5a97..d513e878a 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -197,6 +197,7 @@ public: ALWAYS_COLLECT }; + SPObject(); CObject* cobject; std::set<TypeInfo> typeHierarchy; diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp index 7ab9854d4..3d06e8304 100644 --- a/src/sp-rect.cpp +++ b/src/sp-rect.cpp @@ -31,7 +31,7 @@ #define noRECT_VERBOSE -G_DEFINE_TYPE(SPRect, sp_rect, SP_TYPE_SHAPE); +G_DEFINE_TYPE(SPRect, sp_rect, G_TYPE_OBJECT); static void sp_rect_class_init(SPRectClass *klass) @@ -45,9 +45,9 @@ CRect::CRect(SPRect* rect) : CShape(rect) { CRect::~CRect() { } -static void -sp_rect_init(SPRect *rect) -{ +SPRect::SPRect() : SPShape() { + SPRect* rect = this; + rect->crect = new CRect(rect); rect->typeHierarchy.insert(typeid(SPRect)); @@ -66,6 +66,12 @@ sp_rect_init(SPRect *rect) /* sp_svg_length_unset(&rect->ry, SP_SVG_UNIT_NONE, 0.0, 0.0); */ } +static void +sp_rect_init(SPRect *rect) +{ + new (rect) SPRect(); +} + void CRect::build(SPDocument* doc, Inkscape::XML::Node* repr) { SPRect* object = this->sprect; diff --git a/src/sp-rect.h b/src/sp-rect.h index 0bea4e253..98d4d1924 100644 --- a/src/sp-rect.h +++ b/src/sp-rect.h @@ -28,6 +28,8 @@ class CRect; class SPRect : public SPShape { public: + SPRect(); + CRect* crect; SVGLength x; diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 42b6ec6dd..e3c0301de 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -56,7 +56,7 @@ static void sp_shape_finalize (GObject *object); static void sp_shape_update_marker_view (SPShape *shape, Inkscape::DrawingItem *ai); -G_DEFINE_TYPE(SPShape, sp_shape, SP_TYPE_LPE_ITEM); +G_DEFINE_TYPE(SPShape, sp_shape, G_TYPE_OBJECT); /** * Initializes a SPShapeClass object. Establishes the function pointers to the class' @@ -76,12 +76,10 @@ CShape::CShape(SPShape* shape) : CLPEItem(shape) { CShape::~CShape() { } -/** - * Initializes an SPShape object. - */ -static void -sp_shape_init(SPShape *shape) -{ + +SPShape::SPShape() : SPLPEItem() { + SPShape* shape = this; + shape->cshape = new CShape(shape); shape->typeHierarchy.insert(typeid(SPShape)); @@ -99,6 +97,15 @@ sp_shape_init(SPShape *shape) shape->_curve_before_lpe = NULL; } +/** + * Initializes an SPShape object. + */ +static void +sp_shape_init(SPShape *shape) +{ + new (shape) SPShape(); +} + static void sp_shape_finalize(GObject *object) { diff --git a/src/sp-shape.h b/src/sp-shape.h index e0be6cbea..1a7af4e5e 100644 --- a/src/sp-shape.h +++ b/src/sp-shape.h @@ -38,7 +38,9 @@ class CShape; */ class SPShape : public SPLPEItem { public: + SPShape(); CShape* cshape; + void setShape (); SPCurve * getCurve () const; SPCurve * getCurveBeforeLPE () const; |
