diff options
| author | Jon A. Cruz <jon@joncruz.org> | 2011-07-31 04:48:59 +0000 |
|---|---|---|
| committer | Jon A. Cruz <jon@joncruz.org> | 2011-07-31 04:48:59 +0000 |
| commit | d7cc3ab4cde91c261e13a2a208ed125227e6b30f (patch) | |
| tree | 937f7e33fff59ea0535b8dc92ca995ae339d9fe2 /src | |
| parent | Dutch translation update (diff) | |
| download | inkscape-d7cc3ab4cde91c261e13a2a208ed125227e6b30f.tar.gz inkscape-d7cc3ab4cde91c261e13a2a208ed125227e6b30f.zip | |
Added overload for getObjectById(). Added safety by zeroing out invalid points (prevents accidental use of stale pointers).
(bzr r10521)
Diffstat (limited to 'src')
| -rw-r--r-- | src/document.cpp | 8 | ||||
| -rw-r--r-- | src/document.h | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/document.cpp b/src/document.cpp index 441a5876f..4d1d8780a 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -314,12 +314,15 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, if (document->uri){ g_free(document->uri); + document->uri = 0; } if (document->base){ g_free(document->base); + document->base = 0; } if (document->name){ g_free(document->name); + document->name = 0; } #ifndef WIN32 document->uri = prepend_current_dir_if_relative(uri); @@ -852,6 +855,11 @@ SPDocument::removeUndoObserver(Inkscape::UndoStackObserver& observer) this->priv->undoStackObservers.remove(observer); } +SPObject *SPDocument::getObjectById(Glib::ustring const &id) const +{ + return getObjectById( id.c_str() ); +} + SPObject *SPDocument::getObjectById(gchar const *id) const { g_return_val_if_fail(id != NULL, NULL); diff --git a/src/document.h b/src/document.h index 82a9a5158..c94b66c4d 100644 --- a/src/document.h +++ b/src/document.h @@ -174,6 +174,7 @@ public: sigc::connection connectCommit(CommitSignal::slot_type slot); void bindObjectToId(gchar const *id, SPObject *object); + SPObject *getObjectById(Glib::ustring const &id) const; SPObject *getObjectById(gchar const *id) const; sigc::connection connectIdChanged(const gchar *id, IDChangedSignal::slot_type slot); |
