From: Jon A. Cruz Date: Sun, 4 Apr 2010 00:17:51 +0000 (-0700) Subject: zero out pointers to deleted members. might expose problems if a stail pointer is... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=6a8f101b0d8f2b5880d603b47a35060e1c465cd3;p=inkscape.git zero out pointers to deleted members. might expose problems if a stail pointer is related to bug #494722. --- diff --git a/src/ui/dialog/dialog.cpp b/src/ui/dialog/dialog.cpp index 2b39eb3c9..2483dc50e 100644 --- a/src/ui/dialog/dialog.cpp +++ b/src/ui/dialog/dialog.cpp @@ -139,6 +139,7 @@ Dialog::~Dialog() save_geometry(); delete _behavior; + _behavior = 0; } diff --git a/src/ui/dialog/dialog.h b/src/ui/dialog/dialog.h index 1a59a236c..f07c1bc86 100644 --- a/src/ui/dialog/dialog.h +++ b/src/ui/dialog/dialog.h @@ -21,9 +21,9 @@ class SPDesktop; -namespace Inkscape { -class Selection; -class Application; +namespace Inkscape { +class Selection; +class Application; } namespace Inkscape { @@ -36,7 +36,7 @@ void sp_retransientize(Inkscape::Application *inkscape, SPDesktop *desktop, gpoi gboolean sp_retransientize_again(gpointer dlgPtr); void sp_dialog_shutdown(GtkObject *object, gpointer dlgPtr); -/** +/** * @brief Base class for Inkscape dialogs * This class provides certain common behaviors and styles wanted of all dialogs * in the application. Fundamental parts of the dialog's behavior are controlled by @@ -46,7 +46,7 @@ class Dialog { public: - Dialog(Behavior::BehaviorFactory behavior_factory, const char *prefs_path = NULL, + Dialog(Behavior::BehaviorFactory behavior_factory, const char *prefs_path = NULL, int verb_num = 0, Glib::ustring const &apply_label = ""); virtual ~Dialog(); diff --git a/src/ui/dialog/floating-behavior.cpp b/src/ui/dialog/floating-behavior.cpp index 19147f2c7..85f078439 100644 --- a/src/ui/dialog/floating-behavior.cpp +++ b/src/ui/dialog/floating-behavior.cpp @@ -33,11 +33,11 @@ FloatingBehavior::FloatingBehavior(Dialog &dialog) : Behavior(dialog), _d (new Gtk::Dialog(_dialog._title)) #if GTK_VERSION_GE(2, 12) - ,_dialog_active(_d->property_is_active()) - ,_steps(0) - ,_trans_focus(Inkscape::Preferences::get()->getDoubleLimited("/dialogs/transparency/on-focus", 0.95, 0.0, 1.0)) - ,_trans_blur(Inkscape::Preferences::get()->getDoubleLimited("/dialogs/transparency/on-blur", 0.50, 0.0, 1.0)) - ,_trans_time(Inkscape::Preferences::get()->getIntLimited("/dialogs/transparency/animate-time", 100, 0, 5000)) + ,_dialog_active(_d->property_is_active()) + ,_steps(0) + ,_trans_focus(Inkscape::Preferences::get()->getDoubleLimited("/dialogs/transparency/on-focus", 0.95, 0.0, 1.0)) + ,_trans_blur(Inkscape::Preferences::get()->getDoubleLimited("/dialogs/transparency/on-blur", 0.50, 0.0, 1.0)) + ,_trans_time(Inkscape::Preferences::get()->getIntLimited("/dialogs/transparency/animate-time", 100, 0, 5000)) #endif { hide(); @@ -49,8 +49,8 @@ FloatingBehavior::FloatingBehavior(Dialog &dialog) : _dialog.retransientize_suppress = false; #if GTK_VERSION_GE(2, 12) - _focus_event(); - _dialog_active.signal_changed().connect(sigc::mem_fun(this, &FloatingBehavior::_focus_event)); + _focus_event(); + _dialog_active.signal_changed().connect(sigc::mem_fun(this, &FloatingBehavior::_focus_event)); #endif } @@ -58,12 +58,12 @@ FloatingBehavior::FloatingBehavior(Dialog &dialog) : #if GTK_VERSION_GE(2, 12) /** \brief A function called when the window gets focus - This function gets called on a focus event. It figures out how much - time is required for a transition, and the number of steps that'll take, - and sets up the _trans_timer function to do the work. If the transition - time is set to 0 ms it just calls _trans_timer once with _steps equal to - zero so that the transition happens instantaneously. This occurs on - windows as opacity changes cause flicker there. + This function gets called on a focus event. It figures out how much + time is required for a transition, and the number of steps that'll take, + and sets up the _trans_timer function to do the work. If the transition + time is set to 0 ms it just calls _trans_timer once with _steps equal to + zero so that the transition happens instantaneously. This occurs on + windows as opacity changes cause flicker there. */ void FloatingBehavior::_focus_event (void) { @@ -93,42 +93,43 @@ void FloatingBehavior::_focus_event (void) /** \brief Move the opacity of a window towards our goal - This is a timer function that is set up by _focus_event to slightly - move the opacity of the window along in an animated fashion. It moves - the opacity half way to the goal until it runs out of steps, and then - it just forces the goal. + This is a timer function that is set up by _focus_event to slightly + move the opacity of the window along in an animated fashion. It moves + the opacity half way to the goal until it runs out of steps, and then + it just forces the goal. */ bool FloatingBehavior::_trans_timer (void) { - // printf("Go go gadget timer: %d\n", _steps); - if (_steps == 0) { - if (_dialog_active.get_value()) { - _d->set_opacity(_trans_focus); - } else { - _d->set_opacity(_trans_blur); - } - - return false; - } - - float goal, current; - goal = current = _d->get_opacity(); - - if (_dialog_active.get_value()) { - goal = _trans_focus; - } else { - goal = _trans_blur; - } - - _d->set_opacity(current - ((current - goal) / 2)); - _steps--; - return true; + // printf("Go go gadget timer: %d\n", _steps); + if (_steps == 0) { + if (_dialog_active.get_value()) { + _d->set_opacity(_trans_focus); + } else { + _d->set_opacity(_trans_blur); + } + + return false; + } + + float goal, current; + goal = current = _d->get_opacity(); + + if (_dialog_active.get_value()) { + goal = _trans_focus; + } else { + goal = _trans_blur; + } + + _d->set_opacity(current - ((current - goal) / 2)); + _steps--; + return true; } #endif -FloatingBehavior::~FloatingBehavior() -{ +FloatingBehavior::~FloatingBehavior() +{ delete _d; + _d = 0; } Behavior * @@ -184,9 +185,9 @@ FloatingBehavior::onDesktopActivated (SPDesktop *desktop) #ifdef WIN32 // Win32 special code to enable transient dialogs transient_policy = 2; -#endif +#endif - if (!transient_policy) + if (!transient_policy) return; GtkWindow *dialog_win = GTK_WINDOW(_d->gobj()); diff --git a/src/ui/dialog/floating-behavior.h b/src/ui/dialog/floating-behavior.h index 0360ccf49..30ecaa053 100644 --- a/src/ui/dialog/floating-behavior.h +++ b/src/ui/dialog/floating-behavior.h @@ -64,14 +64,14 @@ private: Gtk::Dialog *_d; //< the actual dialog #if GTK_VERSION_GE(2, 12) - void _focus_event (void); - bool _trans_timer (void); - - Glib::PropertyProxy_ReadOnly _dialog_active; //< Variable proxy to track whether the dialog is the active window - int _steps; //< Number of steps for the timer to animate the transparent dialog - float _trans_focus; //< The percentage opacity when the dialog is focused - float _trans_blur; //< The percentage opactiy when the dialog is not focused - int _trans_time; //< The amount of time (in ms) for the dialog to change it's transparency + void _focus_event (void); + bool _trans_timer (void); + + Glib::PropertyProxy_ReadOnly _dialog_active; //< Variable proxy to track whether the dialog is the active window + int _steps; //< Number of steps for the timer to animate the transparent dialog + float _trans_focus; //< The percentage opacity when the dialog is focused + float _trans_blur; //< The percentage opactiy when the dialog is not focused + int _trans_time; //< The amount of time (in ms) for the dialog to change it's transparency #endif };