From: gouldtj Date: Sat, 1 Sep 2007 04:34:22 +0000 (+0000) Subject: r16406@tres: ted | 2007-08-29 20:14:55 -0700 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=7ee3c5bd8f5f48cbbcfcf276529d8b8460bab5b8;p=inkscape.git r16406@tres: ted | 2007-08-29 20:14:55 -0700 Reroute the way that the preferences signal changes so that pinning works as expected. Fixes a segmentation fault. --- diff --git a/src/extension/effect.cpp b/src/extension/effect.cpp index fc8715248..a20f1c6e9 100644 --- a/src/extension/effect.cpp +++ b/src/extension/effect.cpp @@ -210,13 +210,12 @@ Effect::prefs (Inkscape::UI::View::View * doc) set_state(Extension::STATE_LOADED); if (!loaded()) return false; - sigc::signal changeSignal; + sigc::signal * changeSignal = new sigc::signal; Gtk::Widget * controls; - controls = imp->prefs_effect(this, doc, &changeSignal); + controls = imp->prefs_effect(this, doc, changeSignal); - ExecutionEnv executionEnv(this, doc, controls); - changeSignal.connect(sigc::mem_fun(executionEnv, &ExecutionEnv::preferencesChange)); + ExecutionEnv executionEnv(this, doc, controls, changeSignal); timer->lock(); executionEnv.run(); diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp index 666270d5f..caef5033a 100644 --- a/src/extension/execution-env.cpp +++ b/src/extension/execution-env.cpp @@ -28,7 +28,7 @@ namespace Inkscape { namespace Extension { -ExecutionEnv::ExecutionEnv (Effect * effect, Inkscape::UI::View::View * doc, Gtk::Widget * controls, Gtk::Dialog * prefDialog) : +ExecutionEnv::ExecutionEnv (Effect * effect, Inkscape::UI::View::View * doc, Gtk::Widget * controls, sigc::signal * changeSignal, Gtk::Dialog * prefDialog) : _visibleDialog(NULL), _effect(effect), _prefsVisible(false), @@ -38,6 +38,7 @@ ExecutionEnv::ExecutionEnv (Effect * effect, Inkscape::UI::View::View * doc, Gtk _prefsChanged(false), _livePreview(true), _selfdelete(false), + _changeSignal(changeSignal), _doc(doc) { SPDesktop *desktop = (SPDesktop *)_doc; @@ -67,15 +68,23 @@ ExecutionEnv::ExecutionEnv (Effect * effect, Inkscape::UI::View::View * doc, Gtk _visibleDialog = prefDialog; _prefsVisible = true; } + + if (_changeSignal != NULL) { + _changesig = _changeSignal->connect(sigc::mem_fun(this, &ExecutionEnv::preferencesChange)); + } return; } ExecutionEnv::~ExecutionEnv (void) { _dialogsig.disconnect(); + _changesig.disconnect(); if (_visibleDialog != NULL && !_shutdown) { delete _visibleDialog; } + if (_changeSignal != NULL && !_shutdown) { + delete _changeSignal; + } return; } @@ -96,11 +105,7 @@ ExecutionEnv::preferencesChange (void) { void ExecutionEnv::createPrefsDialog (Gtk::Widget * controls) { - if (_visibleDialog != NULL) { - delete _visibleDialog; - } - - _visibleDialog = new PrefDialog(_effect->get_name(), _effect->get_help(), controls, this, _effect); + _visibleDialog = new PrefDialog(_effect->get_name(), _effect->get_help(), controls, this, _effect, _changeSignal); _visibleDialog->signal_response().connect(sigc::mem_fun(this, &ExecutionEnv::preferencesResponse)); _visibleDialog->show(); _dialogsig = _visibleDialog->signal_response().connect(sigc::mem_fun(this, &ExecutionEnv::preferencesResponse)); @@ -114,6 +119,9 @@ ExecutionEnv::createWorkingDialog (void) { if (_visibleDialog != NULL) { delete _visibleDialog; } + if (_changeSignal != NULL) { + delete _changeSignal; + } gchar * dlgmessage = g_strdup_printf(_("'%s' working, please wait..."), _effect->get_name()); _visibleDialog = new Gtk::MessageDialog(dlgmessage, diff --git a/src/extension/execution-env.h b/src/extension/execution-env.h index 5758658f3..85e97ef18 100644 --- a/src/extension/execution-env.h +++ b/src/extension/execution-env.h @@ -33,15 +33,17 @@ private: bool _prefsChanged; bool _livePreview; bool _selfdelete; + sigc::signal * _changeSignal; Glib::RefPtr _mainloop; Inkscape::UI::View::View * _doc; std::list _selected; sigc::connection _dialogsig; + sigc::connection _changesig; public: Effect * _effect; - ExecutionEnv (Effect * effect, Inkscape::UI::View::View * doc, Gtk::Widget * controls = NULL, Gtk::Dialog * prefDialog = NULL); + ExecutionEnv (Effect * effect, Inkscape::UI::View::View * doc, Gtk::Widget * controls = NULL, sigc::signal * changeSignal = NULL, Gtk::Dialog * prefDialog = NULL); ~ExecutionEnv (void); void run (void); diff --git a/src/extension/prefdialog.cpp b/src/extension/prefdialog.cpp index 7da2a9e29..cef642d50 100644 --- a/src/extension/prefdialog.cpp +++ b/src/extension/prefdialog.cpp @@ -38,7 +38,7 @@ namespace Extension { in the title. It adds a few buttons and sets up handlers for them. It also places the passed in widgets into the dialog. */ -PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * controls, ExecutionEnv * exEnv, Effect * effect) : +PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * controls, ExecutionEnv * exEnv, Effect * effect, sigc::signal * changeSignal) : Gtk::Dialog::Dialog(_(name.c_str()), true, true), _help(help), _name(name), @@ -50,7 +50,8 @@ PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * co _button_pinned(NULL), _param_preview(NULL), _param_pinned(NULL), - _effect(effect) + _effect(effect), + _signal_param_change(changeSignal) { Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox()); hbox->pack_start(*controls, true, true, 6); @@ -182,7 +183,7 @@ PrefDialog::pinned_toggle (void) { _button_cancel->set_label(Gtk::Stock::CANCEL.id); if (_exEnv == NULL) { - _exEnv = new ExecutionEnv(_effect, SP_ACTIVE_DESKTOP, NULL, this); + _exEnv = new ExecutionEnv(_effect, SP_ACTIVE_DESKTOP, NULL, _signal_param_change, this); _createdExEnv = true; preview_toggle(); _exEnv->run(); @@ -201,6 +202,12 @@ PrefDialog::on_response (int signal) { if (signal == Gtk::RESPONSE_OK) { _effect->effect(SP_ACTIVE_DESKTOP); + } else { + this->hide(); + delete _signal_param_change; // This is not in the destructor because + // it is the only situation that we need + // to delete it in + delete this; } this->hide(); diff --git a/src/extension/prefdialog.h b/src/extension/prefdialog.h index 0f385922f..243f92416 100644 --- a/src/extension/prefdialog.h +++ b/src/extension/prefdialog.h @@ -59,6 +59,8 @@ class PrefDialog : public Gtk::Dialog { sigc::signal _signal_preview; /** \brief Signal that the user is changing the pinned state */ sigc::signal _signal_pinned; + /** \brief Signal that one of the parameters change */ + sigc::signal * _signal_param_change; Effect * _effect; @@ -72,7 +74,8 @@ public: gchar const * help, Gtk::Widget * controls, ExecutionEnv * exEnv = NULL, - Effect * effect = NULL); + Effect * effect = NULL, + sigc::signal * changeSignal = NULL); ~PrefDialog (); int run (void);