diff options
| author | Martin Owens <doctormo@gmail.com> | 2014-03-28 21:16:35 +0000 |
|---|---|---|
| committer | Martin Owens <doctormo@gmail.com> | 2014-03-28 21:16:35 +0000 |
| commit | b8a04c5946f23e3cc09e398d1b6603bbba6ceed9 (patch) | |
| tree | ad79dc7432dda707322d605722790975ad23b4b2 /src | |
| parent | Remove _onApply and strdup the char from the label before it gets corrupted. ... (diff) | |
| download | inkscape-b8a04c5946f23e3cc09e398d1b6603bbba6ceed9.tar.gz inkscape-b8a04c5946f23e3cc09e398d1b6603bbba6ceed9.zip | |
Guides: Clean up memory a bit better and move color changed to OK so we don't set the colour before OK
(bzr r13228)
Diffstat (limited to 'src')
| -rw-r--r-- | src/sp-guide.cpp | 2 | ||||
| -rw-r--r-- | src/ui/dialog/guides.cpp | 33 | ||||
| -rw-r--r-- | src/ui/dialog/guides.h | 1 |
3 files changed, 16 insertions, 20 deletions
diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index a0aa9692e..60f15a79d 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -183,6 +183,8 @@ void SPGuide::release() { void SPGuide::set(unsigned int key, const gchar *value) { switch (key) { case SP_ATTR_INKSCAPE_LABEL: + if (this->label) g_free(this->label); + if (value) { this->label = g_strdup(value); } else { diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp index 0e754106d..80740113c 100644 --- a/src/ui/dialog/guides.cpp +++ b/src/ui/dialog/guides.cpp @@ -68,20 +68,6 @@ void GuidelinePropertiesDialog::showDialog(SPGuide *guide, SPDesktop *desktop) { dialog.run(); } -void GuidelinePropertiesDialog::_colorChanged() -{ -#if WITH_GTKMM_3_0 - const Gdk::RGBA c = _color.get_rgba(); - unsigned r = c.get_red_u()/257, g = c.get_green_u()/257, b = c.get_blue_u()/257; -#else - const Gdk::Color c = _color.get_color(); - unsigned r = c.get_red()/257, g = c.get_green()/257, b = c.get_blue()/257; -#endif - //TODO: why 257? verify this! - - sp_guide_set_color(*_guide, r, g, b, true); -} - void GuidelinePropertiesDialog::_modeChanged() { _mode = !_relative_toggle.get_active(); @@ -124,9 +110,21 @@ void GuidelinePropertiesDialog::_onOK() sp_guide_moveto(*_guide, newpos, true); - const gchar* name = _label_entry.getEntry()->get_text().c_str(); + const gchar* name = g_strdup( _label_entry.getEntry()->get_text().c_str() ); - sp_guide_set_label(*_guide, g_strdup(name), true); + sp_guide_set_label(*_guide, name, true); + g_free((gpointer) name); + +#if WITH_GTKMM_3_0 + const Gdk::RGBA c = _color.get_rgba(); + unsigned r = c.get_red_u()/257, g = c.get_green_u()/257, b = c.get_blue_u()/257; +#else + const Gdk::Color c = _color.get_color(); + unsigned r = c.get_red()/257, g = c.get_green()/257, b = c.get_blue()/257; +#endif + //TODO: why 257? verify this! + + sp_guide_set_color(*_guide, r, g, b, true); DocumentUndo::done(_guide->document, SP_VERB_NONE, _("Set guide properties")); @@ -214,9 +212,6 @@ void GuidelinePropertiesDialog::_setup() { 1, 3, 3, 4, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); #endif - _color.signal_color_set().connect(sigc::mem_fun(*this, &GuidelinePropertiesDialog::_colorChanged)); - - // unitmenus /* fixme: We should allow percents here too, as percents of the canvas size */ _unit_menu.setUnitType(UNIT_TYPE_LINEAR); diff --git a/src/ui/dialog/guides.h b/src/ui/dialog/guides.h index 76b830e70..22bf5097a 100644 --- a/src/ui/dialog/guides.h +++ b/src/ui/dialog/guides.h @@ -67,7 +67,6 @@ protected: void _response(gint response); void _modeChanged(); - void _colorChanged(); private: GuidelinePropertiesDialog(GuidelinePropertiesDialog const &); // no copy |
