summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2007-09-01 04:33:48 +0000
committergouldtj <gouldtj@users.sourceforge.net>2007-09-01 04:33:48 +0000
commit26246a2cd104f3548b32a6398d92154b28e08d23 (patch)
treeed0b3cf0dae6da2adc854d151fc728d9b33b4fb7
parent(bzr r3641) (diff)
downloadinkscape-26246a2cd104f3548b32a6398d92154b28e08d23.tar.gz
inkscape-26246a2cd104f3548b32a6398d92154b28e08d23.zip
r16403@tres: ted | 2007-08-29 09:10:45 -0700
Fixed a tricky segmentation fault. Multithreading is hard when you don't have threads :) (bzr r3642)
-rw-r--r--src/extension/execution-env.cpp37
-rw-r--r--src/extension/execution-env.h3
-rw-r--r--src/extension/prefdialog.cpp5
3 files changed, 33 insertions, 12 deletions
diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp
index fcf60cdcb..88cd1af7d 100644
--- a/src/extension/execution-env.cpp
+++ b/src/extension/execution-env.cpp
@@ -29,14 +29,15 @@ namespace Extension {
ExecutionEnv::ExecutionEnv (Effect * effect, Inkscape::UI::View::View * doc, Gtk::Widget * controls, Gtk::Dialog * prefDialog) :
- _effect(effect),
_visibleDialog(NULL),
+ _effect(effect),
_prefsVisible(false),
_finished(false),
_humanWait(false),
_canceled(false),
_prefsChanged(false),
_livePreview(true),
+ _selfdelete(false),
_doc(doc) {
SPDesktop *desktop = (SPDesktop *)_doc;
@@ -49,7 +50,7 @@ ExecutionEnv::ExecutionEnv (Effect * effect, Inkscape::UI::View::View * doc, Gtk
Glib::ustring selected_id;
selected_id = SP_OBJECT_ID(*selected);
_selected.insert(_selected.end(), selected_id);
- //std::cout << "Selected: " << selected_id << std::endl;
+ std::cout << "Selected: " << selected_id << std::endl;
++selected;
}
}
@@ -110,7 +111,7 @@ ExecutionEnv::createPrefsDialog (Gtk::Widget * controls) {
void
ExecutionEnv::createWorkingDialog (void) {
- printf("Create working dialog\n");
+ printf("Create working dialog. doc: %X\n", _doc);
if (_visibleDialog != NULL) {
delete _visibleDialog;
}
@@ -193,17 +194,28 @@ ExecutionEnv::documentCommit (void) {
void
ExecutionEnv::reselect (void) {
+ printf("A doc: %X\n", _doc);
+ if (_doc == NULL) { return; }
SPDocument * doc = _doc->doc();
+ if (doc == NULL) { return; }
+ printf("B doc: %X\n", _doc);
SPDesktop *desktop = (SPDesktop *)_doc;
sp_namedview_document_from_window(desktop);
if (desktop == NULL) { return; }
+ printf("C doc: %X\n", _doc);
Inkscape::Selection * selection = sp_desktop_selection(desktop);
+ printf("D doc: %X\n", _doc);
for (std::list<Glib::ustring>::iterator i = _selected.begin(); i != _selected.end(); i++) {
- selection->add(doc->getObjectById(i->c_str()));
+ printf("E %s doc: %X\n", i->c_str(), _doc);
+ SPObject * obj = doc->getObjectById(i->c_str());
+ printf("F %s doc: %X\n", i->c_str(), _doc);
+ if (obj != NULL) {
+ selection->add(obj);
+ }
}
return;
@@ -221,11 +233,16 @@ ExecutionEnv::run (void) {
processingComplete();
}
if (_canceled) {
+ printf("Canceling the document doc: %X\n", _doc);
sp_document_cancel(_doc->doc());
+ printf("Reselecting doc: %X\n", _doc);
reselect();
}
}
printf("Execution environment done running\n");
+ if (_selfdelete) {
+ delete this;
+ }
return;
}
@@ -243,13 +260,19 @@ ExecutionEnv::livePreview (bool state) {
}
void
-ExecutionEnv::shutdown (void) {
- _mainloop->quit();
- processingCancel();
+ExecutionEnv::shutdown (bool del) {
+ printf("Shutting down Execution Environment\n");
+ if (_humanWait) {
+ _mainloop->quit();
+ } else {
+ processingCancel();
+ }
documentCancel();
+
_finished = true;
_visibleDialog = NULL;
}
+ _selfdelete = del;
return;
}
diff --git a/src/extension/execution-env.h b/src/extension/execution-env.h
index a3938be3d..5758658f3 100644
--- a/src/extension/execution-env.h
+++ b/src/extension/execution-env.h
@@ -32,6 +32,7 @@ private:
bool _canceled;
bool _prefsChanged;
bool _livePreview;
+ bool _selfdelete;
Glib::RefPtr<Glib::MainLoop> _mainloop;
Inkscape::UI::View::View * _doc;
std::list<Glib::ustring> _selected;
@@ -46,7 +47,7 @@ public:
void run (void);
void preferencesChange (void);
void livePreview (bool state = true);
- void shutdown (void);
+ void shutdown (bool del = false);
private:
void createPrefsDialog (Gtk::Widget * controls);
diff --git a/src/extension/prefdialog.cpp b/src/extension/prefdialog.cpp
index 62e6b9ff8..4676661b1 100644
--- a/src/extension/prefdialog.cpp
+++ b/src/extension/prefdialog.cpp
@@ -171,10 +171,7 @@ PrefDialog::pinned_toggle (void) {
_button_cancel->set_label(Gtk::Stock::CLOSE.id);
if (_exEnv != NULL) {
- _exEnv->shutdown();
- if (_createdExEnv) {
- delete _exEnv;
- }
+ _exEnv->shutdown(_createdExEnv);
_exEnv = NULL;
}
} else {