diff --git a/src/inkscape.cpp b/src/inkscape.cpp
index f976f668220d9b9116fe25d7ecc58047d6482423..c167be493c0900a05a12b9560472da180c80b6a8 100644 (file)
--- a/src/inkscape.cpp
+++ b/src/inkscape.cpp
#endif
+#include <set>
#include "debug/simple-event.h"
#include "debug/event-tracker.h"
# FORWARD DECLARATIONS
################################*/
-bool inkscape_app_use_gui( Inkscape::Application const * app );
+gboolean inkscape_app_use_gui( Inkscape::Application const * app );
static void inkscape_class_init (Inkscape::ApplicationClass *klass);
static void inkscape_init (SPObject *object);
@@ -109,11 +110,12 @@ 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;
- bool dialogs_toggle;
- bool use_gui; // may want to consider a virtual function
+ gboolean dialogs_toggle;
+ gboolean use_gui; // may want to consider a virtual function
// for overriding things like the warning dlg's
};
static GObjectClass * parent_class;
static guint inkscape_signals[LAST_SIGNAL] = {0};
-static void (* segv_handler) (int) = NULL;
+static void (* segv_handler) (int) = SIG_DFL;
+static void (* abrt_handler) (int) = SIG_DFL;
+static void (* fpe_handler) (int) = SIG_DFL;
+static void (* ill_handler) (int) = SIG_DFL;
+static void (* bus_handler) (int) = SIG_DFL;
#ifdef WIN32
#define INKSCAPE_PROFILE_DIR "Inkscape"
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 ();
static void
-inkscape_segv_handler (int signum)
+inkscape_crash_handler (int signum)
{
using Inkscape::Debug::SimpleEvent;
using Inkscape::Debug::EventTracker;
static gint recursion = FALSE;
- /* let any SIGABRTs seen from within this handler dump core */
- signal(SIGABRT, SIG_DFL);
-
- /* Kill loops */
+ /*
+ * reset all signal handlers: any further crashes should just be allowed
+ * to crash normally.
+ * */
+ signal (SIGSEGV, segv_handler );
+ signal (SIGABRT, abrt_handler );
+ signal (SIGFPE, fpe_handler );
+ signal (SIGILL, ill_handler );
+#ifndef WIN32
+ signal (SIGBUS, bus_handler );
+#endif
+
+ /* Stop bizarre loops */
if (recursion) {
abort ();
}
file = Inkscape::IO::fopen_utf8name(c, "w");
}
if (file) {
- sp_repr_save_stream (sp_repr_document (repr), file, SP_SVG_NS_URI);
+ sp_repr_save_stream (repr->document(), file, SP_SVG_NS_URI);
savednames = g_slist_prepend (savednames, g_strdup (c));
fclose (file);
} else {
tracker.clear();
Logger::shutdown();
- (* segv_handler) (signum);
+ /* on exit, allow restored signal handler to take over and crash us */
}
void
-inkscape_application_init (const gchar *argv0, bool use_gui)
+inkscape_application_init (const gchar *argv0, gboolean use_gui)
{
inkscape = (Inkscape::Application *)g_object_new (SP_TYPE_INKSCAPE, NULL);
/* fixme: load application defaults */
- segv_handler = signal (SIGSEGV, inkscape_segv_handler);
- signal (SIGFPE, inkscape_segv_handler);
- signal (SIGILL, inkscape_segv_handler);
+ segv_handler = signal (SIGSEGV, inkscape_crash_handler);
+ abrt_handler = signal (SIGABRT, inkscape_crash_handler);
+ fpe_handler = signal (SIGFPE, inkscape_crash_handler);
+ ill_handler = signal (SIGILL, inkscape_crash_handler);
#ifndef WIN32
- signal (SIGBUS, inkscape_segv_handler);
+ bus_handler = signal (SIGBUS, inkscape_crash_handler);
#endif
- signal (SIGABRT, inkscape_segv_handler);
inkscape->use_gui = use_gui;
inkscape->argv0 = g_strdup(argv0);
return inkscape;
}
-bool inkscape_app_use_gui( Inkscape::Application const * app )
+gboolean inkscape_app_use_gui( Inkscape::Application const * app )
{
return app->use_gui;
}
@@ -645,7 +664,7 @@ inkscape_load_config (const gchar *filename, Inkscape::XML::Document *config, co
return false;
}
- Inkscape::XML::Node *root = sp_repr_document_root (doc);
+ Inkscape::XML::Node *root = doc->root();
if (strcmp (root->name(), "inkscape")) {
gchar *safeFn = Inkscape::IO::sanitizeString(fn);
GtkWidget *w = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, e_notsp, safeFn, warn);
Inkscape::XML::Node *
inkscape_get_repr (Inkscape::Application *inkscape, const gchar *key)
{
- if (key == NULL) {
+ if ( (key == NULL) || (inkscape == NULL) ) {
return NULL;
}
- Inkscape::XML::Node *repr = sp_repr_document_root (Inkscape::Preferences::get());
+ Inkscape::XML::Node *prefs = Inkscape::Preferences::get();
+ if ( !prefs ) {
+ return NULL;
+ }
+
+ Inkscape::XML::Node *repr = prefs->root();
+ if (!repr) return NULL;
g_assert (!(strcmp (repr->name(), "inkscape")));
gchar const *s = key;
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
{
@@ -1213,6 +1243,29 @@ inkscape_init_config (Inkscape::XML::Document *doc, const gchar *config_name, co
return false;
}
}
+
+ // Also create (empty for now) subdirectories for the user's stuff
+ {
+ gchar *temp_dn = profile_path("templates");
+ Inkscape::IO::mkdir_utf8name(temp_dn);
+ }
+ {
+ gchar *temp_dn = profile_path("keys");
+ Inkscape::IO::mkdir_utf8name(temp_dn);
+ }
+ {
+ gchar *temp_dn = profile_path("icons");
+ Inkscape::IO::mkdir_utf8name(temp_dn);
+ }
+ {
+ gchar *temp_dn = profile_path("extensions");
+ Inkscape::IO::mkdir_utf8name(temp_dn);
+ }
+ {
+ gchar *temp_dn = profile_path("palettes");
+ Inkscape::IO::mkdir_utf8name(temp_dn);
+ }
+
} else if (!Inkscape::IO::file_test(dn, G_FILE_TEST_IS_DIR)) {
if (use_gui) {
// Not a directory
Inkscape::XML::Node *
inkscape_get_menus (Inkscape::Application * inkscape)
{
- Inkscape::XML::Node *repr = sp_repr_document_root (inkscape->menus);
+ Inkscape::XML::Node *repr = inkscape->menus->root();
g_assert (!(strcmp (repr->name(), "inkscape")));
return repr->firstChild();
}