diff --git a/src/uri-references.cpp b/src/uri-references.cpp
index 793e10d98ad0ec280e02a093c746107211655c0d..c9482839d56a5452579583549712eb6ba1b9395d 100644 (file)
--- a/src/uri-references.cpp
+++ b/src/uri-references.cpp
namespace Inkscape {
URIReference::URIReference(SPObject *owner)
-: _owner(owner), _obj(NULL), _uri(NULL)
+ : _owner(owner), _owner_document(NULL), _obj(NULL), _uri(NULL)
{
g_assert(_owner != NULL);
/* FIXME !!! attach to owner's destroy signal to clean up in case */
}
+URIReference::URIReference(SPDocument *owner_document)
+ : _owner(NULL), _owner_document(owner_document), _obj(NULL), _uri(NULL)
+{
+ g_assert(_owner_document != NULL);
+}
+
URIReference::~URIReference() {
detach();
}
void URIReference::attach(const URI &uri) throw(BadURIException)
{
- SPDocument *document = SP_OBJECT_DOCUMENT(_owner);
+ SPDocument *document;
+ if (_owner) {
+ document = SP_OBJECT_DOCUMENT(_owner);
+ } else if (_owner_document) {
+ document = _owner_document;
+ } else {
+ g_assert_not_reached();
+ }
gchar const *fragment = uri.getFragment();
if ( !uri.isRelative() || uri.getQuery() || !fragment ) {
throw UnsupportedURIException();
SPObject *old_obj=_obj;
_obj = obj;
+ _release_connection.disconnect();
if (_obj) {
sp_object_href(_obj, _owner);
_release_connection = _obj->connectRelease(sigc::mem_fun(*this, &URIReference::_release));
}
_changed_signal.emit(old_obj, _obj);
if (old_obj) {
- _release_connection.disconnect();
/* release the old object _after_ the signal emission */
sp_object_hunref(old_obj, _owner);
}