summaryrefslogtreecommitdiffstats
path: root/src/inkscape.cpp
diff options
context:
space:
mode:
authorMenTaLguY <mental@rydia.net>2007-03-23 05:52:15 +0000
committermental <mental@users.sourceforge.net>2007-03-23 05:52:15 +0000
commitf6e71416f19343cb97098c175acce52771e5e32b (patch)
treed487d09840f9cce4372ac89b22f81bf3b2c858e4 /src/inkscape.cpp
parentpurge old toolbar code, fill in values and labels (diff)
downloadinkscape-f6e71416f19343cb97098c175acce52771e5e32b.tar.gz
inkscape-f6e71416f19343cb97098c175acce52771e5e32b.zip
allow multiple (balanced) calls to add and remove document
(bzr r2745)
Diffstat (limited to 'src/inkscape.cpp')
-rw-r--r--src/inkscape.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/inkscape.cpp b/src/inkscape.cpp
index be3ff1e7d..799227bf3 100644
--- a/src/inkscape.cpp
+++ b/src/inkscape.cpp
@@ -18,6 +18,7 @@
#endif
+#include <set>
#include "debug/simple-event.h"
#include "debug/event-tracker.h"
@@ -109,6 +110,7 @@ static bool inkscape_init_config (Inkscape::XML::Document *doc, const gchar *con
struct Inkscape::Application {
GObject object;
Inkscape::XML::Document *menus;
+ std::multiset<SPDocument *> document_set;
GSList *documents;
GSList *desktops;
gchar *argv0;
@@ -292,6 +294,8 @@ inkscape_init (SPObject * object)
g_assert_not_reached ();
}
+ new (&inkscape->document_set) std::multiset<SPDocument *>();
+
inkscape->menus = sp_repr_read_mem (_(menus_skeleton), MENUS_SKELETON_SIZE, NULL);
inkscape->documents = NULL;
@@ -321,6 +325,8 @@ inkscape_dispose (GObject *object)
inkscape->menus = NULL;
}
+ inkscape->document_set.~multiset();
+
G_OBJECT_CLASS (parent_class)->dispose (object);
gtk_main_quit ();
@@ -1112,8 +1118,11 @@ inkscape_add_document (SPDocument *document)
if (!Inkscape::NSApplication::Application::getNewGui())
{
- g_assert (!g_slist_find (inkscape->documents, document));
- inkscape->documents = g_slist_append (inkscape->documents, document);
+ if ( inkscape->document_set.find(document) != inkscape->document_set.end() ) {
+
+ inkscape->documents = g_slist_append (inkscape->documents, document);
+ }
+ inkscape->document_set.insert(document);
}
else
{
@@ -1130,8 +1139,10 @@ inkscape_remove_document (SPDocument *document)
if (!Inkscape::NSApplication::Application::getNewGui())
{
- g_assert (g_slist_find (inkscape->documents, document));
- inkscape->documents = g_slist_remove (inkscape->documents, document);
+ inkscape->document_set.erase(document);
+ if ( inkscape->document_set.find(document) == inkscape->document_set.end() ) {
+ inkscape->documents = g_slist_remove (inkscape->documents, document);
+ }
}
else
{