From 19ba77af95bc8266f504817def29730aa030ee56 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Thu, 27 Oct 2016 01:59:42 +0200 Subject: Prevent image drag/drop from grouping (bzr r15192) --- src/file.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/file.cpp b/src/file.cpp index e5c7240dc..d39d8c6ce 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1193,12 +1193,23 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, // Count the number of top-level items in the imported document. guint items_count = 0; + SPObject *o = NULL; for (auto& child: doc->getRoot()->children) { if (SP_IS_ITEM(&child)) { items_count++; + o = &child; } } + //ungroup if necessary + bool did_ungroup = false; + while(items_count==1 && o && SP_IS_GROUP(o) && o->children.size()==1){ + std::vectorv; + sp_item_group_ungroup(SP_GROUP(o),v,false); + o = v.empty() ? NULL : v[0]; + did_ungroup=true; + } + // Create a new group if necessary. Inkscape::XML::Node *newgroup = NULL; if ((style && style->attributeList()) || items_count > 1) { @@ -1225,7 +1236,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, SPObject *new_obj = NULL; for (auto& child: doc->getRoot()->children) { if (SP_IS_ITEM(&child)) { - Inkscape::XML::Node *newitem = child.getRepr()->duplicate(xml_in_doc); + Inkscape::XML::Node *newitem = did_ungroup ? o->getRepr()->duplicate(xml_in_doc) : child.getRepr()->duplicate(xml_in_doc); // convert layers to groups, and make sure they are unlocked // FIXME: add "preserve layers" mode where each layer from -- cgit v1.2.3 From 71f7e3e517b5d7f87d30a27b683c57df05ab5368 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Thu, 27 Oct 2016 02:01:14 +0200 Subject: Fix regression in loop prevention Fixed bugs: - https://launchpad.net/bugs/1636533 (bzr r15193) --- src/sp-object.cpp | 4 +++- src/sp-object.h | 1 + src/uri-references.cpp | 38 ++++++++++++-------------------------- 3 files changed, 16 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 21d8bcd93..8d4c4f0d1 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -119,7 +119,7 @@ static gchar *sp_object_get_unique_id(SPObject *object, * Constructor, sets all attributes to default values. */ SPObject::SPObject() - : cloned(0), uflags(0), mflags(0), hrefcount(0), _total_hrefcount(0), + : cloned(0), clone_original(NULL), uflags(0), mflags(0), hrefcount(0), _total_hrefcount(0), document(NULL), parent(NULL), id(NULL), repr(NULL), refCount(1), hrefList(std::list()), _successor(NULL), _collection_policy(SPObject::COLLECT_WITH_PARENT), _label(NULL), _default_label(NULL) @@ -663,6 +663,8 @@ void SPObject::build(SPDocument *document, Inkscape::XML::Node *repr) { object->readAttr("xml:space"); object->readAttr("inkscape:label"); object->readAttr("inkscape:collect"); + if(object->cloned) + object->clone_original = document->getObjectById(repr->attribute("id")); for (Inkscape::XML::Node *rchild = repr->firstChild() ; rchild != NULL; rchild = rchild->next()) { const std::string typeString = NodeTraits::get_type_string(*rchild); diff --git a/src/sp-object.h b/src/sp-object.h index ac3d0c851..355f837b5 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -201,6 +201,7 @@ public: virtual ~SPObject(); unsigned int cloned : 1; + SPObject *clone_original; unsigned int uflags : 8; unsigned int mflags : 8; SPIXmlSpace xml_space; diff --git a/src/uri-references.cpp b/src/uri-references.cpp index 07f2d168b..170c98beb 100644 --- a/src/uri-references.cpp +++ b/src/uri-references.cpp @@ -3,6 +3,7 @@ * * Authors: * Lauris Kaplinski + * Marc Jeanmougin * * Copyright (C) 2001-2002 Lauris Kaplinski * Copyright (C) 2001 Ximian, Inc. @@ -48,13 +49,10 @@ URIReference::~URIReference() { detach(); } * The main ideas here are: * (1) "If we are inside a clone, then we can accept if and only if our "original thing" can accept the reference" * (this caused problems when there are clones because a change in ids triggers signals for the object hrefing this id, - *but also its cloned reprs - * (descendants of referencing an ancestor of the href'ing object)). The way it is done here is *atrocious*, but i - *could not find a better way. - * FIXME: find a better and safer way to find the "original object" of anyone with the flag ->cloned + * but also its cloned reprs(descendants of referencing an ancestor of the href'ing object)). * * (2) Once we have an (potential owner) object, it can accept a href to obj, iff the graph of objects where directed - *edges are + * edges are * either parent->child relations , *** or href'ing to href'ed *** relations, stays acyclic. * We can go either from owner and up in the tree, or from obj and down, in either case this will be in the worst case *linear in the number of objects. @@ -70,29 +68,17 @@ bool URIReference::_acceptObject(SPObject *obj) const SPObject *owner = getOwner(); if (!owner) return true; + while (owner->cloned) { - std::vector positions; - while (owner->cloned) { - int position = 0; - for (auto &child: owner->parent->children) { - if(&child == owner) { - break; - } - position++; - } - positions.push_back(position); + if(!owner->clone_original)//happens when the clone is existing and linking to something, even before the original objects exists. + //for instance, it can happen when you paste a filtered object in a already cloned group: The construction of the + //clone representation of the filtered object will finish before the original object, so the cloned repr will + //have to _accept the filter even though the original does not exist yet. In that case, we'll accept iff the parent of the + //original can accept it: loops caused by other relations than parent-child would be prevented when created on their base object. + //Fixes bug 1636533. owner = owner->parent; - } - if (dynamic_cast(owner)) - owner = ((SPUse *)owner)->get_original(); - else if (dynamic_cast(owner)) - owner = ((SPTagUse *)owner)->get_original(); - else { - g_warning("cloned object with no known type\n"); - return false; - } - for (int i = (int) (positions.size() - 2); i >= 0; i--) - owner = owner->childList(false)[positions[i]]; + else + owner = owner->clone_original; } // once we have the "original" object (hopefully) we look at who is referencing it if (obj == owner) -- cgit v1.2.3 From def40c6005ff987960d12403df2d8af259a06b33 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Sat, 29 Oct 2016 00:27:25 +0200 Subject: allows for denser screens in zoom correction factors (bzr r15195) --- src/ui/dialog/inkscape-preferences.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 9a95c3d8c..f9540c989 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -631,7 +631,7 @@ void InkscapePreferences::initPageUI() _page_ui.add_line( false, _("Maximum documents in Open _Recent:"), _misc_recent, "", _("Set the maximum length of the Open Recent list in the File menu, or clear the list"), false, reset_recent); - _ui_zoom_correction.init(300, 30, 1.00, 200.0, 1.0, 10.0, 1.0); + _ui_zoom_correction.init(300, 30, 1.00, 500.0, 1.0, 10.0, 1.0); _page_ui.add_line( false, _("_Zoom correction factor (in %):"), _ui_zoom_correction, "", _("Adjust the slider until the length of the ruler on your screen matches its real length. This information is used when zooming to 1:1, 1:2, etc., to display objects in their true sizes"), true); -- cgit v1.2.3