summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4e93dc3)
raw | patch | inline | side by side (parent: 4e93dc3)
author | mental <mental@users.sourceforge.net> | |
Fri, 23 Mar 2007 05:52:15 +0000 (05:52 +0000) | ||
committer | mental <mental@users.sourceforge.net> | |
Fri, 23 Mar 2007 05:52:15 +0000 (05:52 +0000) |
index 1cc45f3c7ebf5388e55d32fe5ca83aed82b0a418..56984dcbb99095d85b1c65e4ecf0221bffe198ba 100644 (file)
void
Editor::addDocument (SPDocument *doc)
{
- g_assert (!g_slist_find (_instance->_documents, doc));
- _instance->_documents = g_slist_append (_instance->_documents, doc);
+ if ( _instance->_document_set.find(doc) == _instance->_document_set.end() ) {
+ _instance->_documents = g_slist_append (_instance->_documents, doc);
+ }
+ _instance->_document_set.insert(doc);
}
void
Editor::removeDocument (SPDocument *doc)
{
- g_assert (g_slist_find (_instance->_documents, doc));
- _instance->_documents = g_slist_remove (_instance->_documents, doc);
+ _instance->_document_set.erase(doc);
+ if ( _instance->_document_set.find(doc) == _instance->_document_set.end() ) {
+ _instance->_documents = g_slist_remove (_instance->_documents, doc);
+ }
}
SPDesktop*
index 9d2ce493c69bbba73fbb6b080b1a9e6d19ba1807..a6fe66688957af47f46b10ab16c512c250f2f818 100644 (file)
--- a/src/application/editor.h
+++ b/src/application/editor.h
#include <sigc++/sigc++.h>
#include <glib/gslist.h>
#include <glibmm/ustring.h>
+#include <set>
#include "app-prototype.h"
class SPDesktop;
Editor(Editor const &);
Editor& operator=(Editor const &);
+ std::multiset<SPDocument *> _document_set;
GSList *_documents;
GSList *_desktops;
gchar *_argv0;
diff --git a/src/document.cpp b/src/document.cpp
index e66089fedfdcb6ee5a294c64fb1bc1e36bd4b0e1..4dd0f3d211321cf1bb7d1c88e8278327ee57d17b 100644 (file)
--- a/src/document.cpp
+++ b/src/document.cpp
collectOrphans();
if (priv) {
- inkscape_remove_document(this);
-
if (priv->partial) {
sp_repr_free_log(priv->partial);
priv->partial = NULL;
document->_selection_changed_connection = Inkscape::NSApplication::Editor::connectSelectionChanged (sigc::mem_fun (*document, &SPDocument::reset_key));
document->_desktop_activated_connection = Inkscape::NSApplication::Editor::connectDesktopActivated (sigc::mem_fun (*document, &SPDocument::reset_key));
}
- inkscape_add_document(document);
return document;
}
@@ -402,7 +399,6 @@ sp_document_new_from_mem(gchar const *buffer, gint length, unsigned int keepaliv
SPDocument *sp_document_new_dummy() {
SPDocument *document = new SPDocument();
- inkscape_add_document(document);
return document;
}
diff --git a/src/inkscape.cpp b/src/inkscape.cpp
index be3ff1e7d0681de8322e13501c1762cc2bd8c46f..799227bf37c9b2bec2af6b934a6c02ab8d046f99 100644 (file)
--- a/src/inkscape.cpp
+++ b/src/inkscape.cpp
#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;
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;
inkscape->menus = NULL;
}
+ inkscape->document_set.~multiset();
+
G_OBJECT_CLASS (parent_class)->dispose (object);
gtk_main_quit ();
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
{
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
{
diff --git a/src/ui/view/view.cpp b/src/ui/view/view.cpp
index 04158ddbdd74595b759149661ca0839d0026bccf..6b6e0b8b629999b620fe30fa39504ff3552f2de1 100644 (file)
--- a/src/ui/view/view.cpp
+++ b/src/ui/view/view.cpp
#include "message-stack.h"
#include "message-context.h"
#include "verbs.h"
+#include "inkscape-private.h"
namespace Inkscape {
namespace UI {
*/
View::~View()
{
+ if (_doc) {
+ inkscape_remove_document(_doc);
+ }
_close();
}
if (_doc) {
_document_uri_set_connection.disconnect();
_document_resized_connection.disconnect();
+ inkscape_remove_document(_doc);
}
+ inkscape_add_document(doc);
+
_doc = doc;
_document_uri_set_connection =
_doc->connectURISet(sigc::bind(sigc::ptr_fun(&_onDocumentURISet), this));