diff options
| author | Alexander Valavanis <valavanisalex@gmail.com> | 2018-12-01 12:32:12 +0000 |
|---|---|---|
| committer | Alexander Valavanis <valavanisalex@gmail.com> | 2018-12-01 12:32:12 +0000 |
| commit | 212c5b08a1fc3ed62a11f5d19eb1dc8087785321 (patch) | |
| tree | 395c6a5e2b0f64b8ff9e805adeefac694f2d7b37 /src | |
| parent | desktopwidget: C++ify a few members (diff) | |
| parent | Replace void* by SPItem* to avoid static casts. (diff) | |
| download | inkscape-212c5b08a1fc3ed62a11f5d19eb1dc8087785321.tar.gz inkscape-212c5b08a1fc3ed62a11f5d19eb1dc8087785321.zip | |
Merge branch 'master' of gitlab.com:inkscape/inkscape
Diffstat (limited to 'src')
| -rw-r--r-- | src/desktop.cpp | 2 | ||||
| -rw-r--r-- | src/display/drawing-item.cpp | 11 | ||||
| -rw-r--r-- | src/display/drawing-item.h | 7 | ||||
| -rw-r--r-- | src/object/sp-item.cpp | 2 | ||||
| -rw-r--r-- | src/ui/view/svg-view.cpp | 2 |
5 files changed, 13 insertions, 11 deletions
diff --git a/src/desktop.cpp b/src/desktop.cpp index de537ce8b..27d5582f1 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -1742,7 +1742,7 @@ static gint _arena_handler (SPCanvasArena */*arena*/, Inkscape::DrawingItem *ai, GdkEvent *event, SPDesktop *desktop) { if (ai) { - SPItem *spi = (SPItem*) ai->data(); + SPItem *spi = ai->getItem(); return sp_event_context_item_handler (desktop->event_context, spi, event); } else { return sp_event_context_root_handler (desktop->event_context, event); diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index 2a62c4b47..c8499e200 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -25,6 +25,8 @@ #include "display/cairo-utils.h" #include "display/cairo-templates.h" +#include "object/sp-item.h" + namespace Inkscape { void set_cairo_blend_operator( DrawingContext &dc, unsigned blend_mode ) { @@ -119,7 +121,7 @@ DrawingItem::DrawingItem(Drawing &drawing) , _fill_pattern(nullptr) , _stroke_pattern(nullptr) , _filter(nullptr) - , _user_data(nullptr) + , _item(nullptr) , _cache(nullptr) , _state(0) , _child_type(CHILD_ORPHAN) @@ -1030,10 +1032,9 @@ DrawingItem::pick(Geom::Point const &p, double delta, unsigned flags) Glib::ustring DrawingItem::name() { - SPObject *object = static_cast<SPObject *>(_user_data); - if (object) { - if(object->getId()) - return object->getId(); + if (_item) { + if (_item->getId()) + return _item->getId(); else return "No object id"; } else { diff --git a/src/display/drawing-item.h b/src/display/drawing-item.h index 3c3bf8b3f..155551f6a 100644 --- a/src/display/drawing-item.h +++ b/src/display/drawing-item.h @@ -26,6 +26,7 @@ class ustring; } class SPStyle; +class SPItem; namespace Inkscape { @@ -130,8 +131,8 @@ public: void setKey(unsigned key) { _key = key; } unsigned key() const { return _key; } - void setData(void *data) { _user_data = data; } - void *data() const { return _user_data; } + void setItem(SPItem *item) { _item = item; } + SPItem* getItem() const { return _item; } // SPItem void update(Geom::IntRect const &area = Geom::IntRect::infinite(), UpdateContext const &ctx = UpdateContext(), unsigned flags = STATE_ALL, unsigned reset = 0); unsigned render(DrawingContext &dc, Geom::IntRect const &area, unsigned flags = 0, DrawingItem *stop_at = nullptr); @@ -203,7 +204,7 @@ protected: DrawingPattern *_fill_pattern; DrawingPattern *_stroke_pattern; Inkscape::Filters::Filter *_filter; - void *_user_data; ///< Used to associate DrawingItems with SPItems that created them + SPItem *_item; ///< Used to associate DrawingItems with SPItems that created them DrawingCache *_cache; CacheList::iterator _cache_iterator; diff --git a/src/object/sp-item.cpp b/src/object/sp-item.cpp index e9ec95252..6a9bd9615 100644 --- a/src/object/sp-item.cpp +++ b/src/object/sp-item.cpp @@ -1179,7 +1179,7 @@ Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned stroke_ps->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } } - ai->setData(this); + ai->setItem(this); ai->setItemBounds(geometricBounds()); } diff --git a/src/ui/view/svg-view.cpp b/src/ui/view/svg-view.cpp index e86228322..14ced7fac 100644 --- a/src/ui/view/svg-view.cpp +++ b/src/ui/view/svg-view.cpp @@ -142,7 +142,7 @@ static gint arena_handler(SPCanvasArena */*arena*/, Inkscape::DrawingItem *ai, G static gboolean active = FALSE; SPEvent spev; - SPItem *spitem = (ai) ? (static_cast<SPItem*>(ai->data())) : nullptr; + SPItem *spitem = (ai) ? ai->getItem() : nullptr; switch (event->type) { case GDK_BUTTON_PRESS: |
