diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2014-12-26 18:49:12 +0000 |
|---|---|---|
| committer | tavmjong-free <tavmjong@free.fr> | 2014-12-26 18:49:12 +0000 |
| commit | 74f6d0cf39c974ca1980a7be7742f2154d2025f2 (patch) | |
| tree | f98b503be33ccc32c1074c5c670a0cd9b5fb5332 /src/ui | |
| parent | Documentation. Fix for bug #1405653 (Outdated links in hacking doc). (diff) | |
| parent | SPStyle ref counting clean up. (diff) | |
| download | inkscape-74f6d0cf39c974ca1980a7be7742f2154d2025f2.tar.gz inkscape-74f6d0cf39c974ca1980a7be7742f2154d2025f2.zip | |
Replace sp_style_xxx functions with SPStyle member functions.
Fix a bunch of memory leaks. One leak still remaining in Layout::appendText.
(bzr r13824)
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/dialog/glyphs.cpp | 9 | ||||
| -rw-r--r-- | src/ui/dialog/swatches.cpp | 24 | ||||
| -rw-r--r-- | src/ui/dialog/text-edit.cpp | 31 | ||||
| -rw-r--r-- | src/ui/tools/freehand-base.cpp | 19 | ||||
| -rw-r--r-- | src/ui/widget/object-composite-settings.cpp | 16 | ||||
| -rw-r--r-- | src/ui/widget/selected-style.cpp | 26 | ||||
| -rw-r--r-- | src/ui/widget/style-swatch.cpp | 9 |
7 files changed, 60 insertions, 74 deletions
diff --git a/src/ui/dialog/glyphs.cpp b/src/ui/dialog/glyphs.cpp index 9bad90e7c..2b9053da9 100644 --- a/src/ui/dialog/glyphs.cpp +++ b/src/ui/dialog/glyphs.cpp @@ -709,13 +709,12 @@ void GlyphsPanel::readSelection( bool updateStyle, bool /*updateContent*/ ) calcCanInsert(); if (targetDesktop && updateStyle) { - //SPStyle *query = sp_style_new(SP_ACTIVE_DOCUMENT); + //SPStyle query(SP_ACTIVE_DOCUMENT); - //int result_family = sp_desktop_query_style(targetDesktop, query, QUERY_STYLE_PROPERTY_FONTFAMILY); - //int result_style = sp_desktop_query_style(targetDesktop, query, QUERY_STYLE_PROPERTY_FONTSTYLE); - //int result_numbers = sp_desktop_query_style(targetDesktop, query, QUERY_STYLE_PROPERTY_FONTNUMBERS); + //int result_family = sp_desktop_query_style(targetDesktop, &query, QUERY_STYLE_PROPERTY_FONTFAMILY); + //int result_style = sp_desktop_query_style(targetDesktop, &query, QUERY_STYLE_PROPERTY_FONTSTYLE); + //int result_numbers = sp_desktop_query_style(targetDesktop, &query, QUERY_STYLE_PROPERTY_FONTNUMBERS); - //sp_style_unref(query); } } diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 772217fcd..8759039c3 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -125,12 +125,12 @@ static void editGradientImpl( SPDesktop* desktop, SPGradient* gr ) Inkscape::Selection *selection = desktop->getSelection(); GSList const *items = selection->itemList(); if (items) { - SPStyle *query = sp_style_new( desktop->doc() ); - int result = objects_query_fillstroke(const_cast<GSList *>(items), query, true); + SPStyle query( desktop->doc() ); + int result = objects_query_fillstroke(const_cast<GSList *>(items), &query, true); if ( (result == QUERY_STYLE_MULTIPLE_SAME) || (result == QUERY_STYLE_SINGLE) ) { // could be pertinent - if (query->fill.isPaintserver()) { - SPPaintServer* server = query->getFillPaintServer(); + if (query.fill.isPaintserver()) { + SPPaintServer* server = query.getFillPaintServer(); if ( SP_IS_GRADIENT(server) ) { SPGradient* grad = SP_GRADIENT(server); if ( grad->isSwatch() && grad->getId() == gr->getId()) { @@ -140,7 +140,6 @@ static void editGradientImpl( SPDesktop* desktop, SPGradient* gr ) } } } - sp_style_unref(query); } } @@ -1061,15 +1060,15 @@ void SwatchesPanel::_updateFromSelection() Glib::ustring fillId; Glib::ustring strokeId; - SPStyle *tmpStyle = sp_style_new(_currentDesktop->getDocument()); - int result = sp_desktop_query_style( _currentDesktop, tmpStyle, QUERY_STYLE_PROPERTY_FILL ); + SPStyle tmpStyle(_currentDesktop->getDocument()); + int result = sp_desktop_query_style( _currentDesktop, &tmpStyle, QUERY_STYLE_PROPERTY_FILL ); switch (result) { case QUERY_STYLE_SINGLE: case QUERY_STYLE_MULTIPLE_AVERAGED: case QUERY_STYLE_MULTIPLE_SAME: { - if (tmpStyle->fill.set && tmpStyle->fill.isPaintserver()) { - SPPaintServer* server = tmpStyle->getFillPaintServer(); + if (tmpStyle.fill.set && tmpStyle.fill.isPaintserver()) { + SPPaintServer* server = tmpStyle.getFillPaintServer(); if ( SP_IS_GRADIENT(server) ) { SPGradient* target = 0; SPGradient* grad = SP_GRADIENT(server); @@ -1095,14 +1094,14 @@ void SwatchesPanel::_updateFromSelection() } } - result = sp_desktop_query_style( _currentDesktop, tmpStyle, QUERY_STYLE_PROPERTY_STROKE ); + result = sp_desktop_query_style( _currentDesktop, &tmpStyle, QUERY_STYLE_PROPERTY_STROKE ); switch (result) { case QUERY_STYLE_SINGLE: case QUERY_STYLE_MULTIPLE_AVERAGED: case QUERY_STYLE_MULTIPLE_SAME: { - if (tmpStyle->stroke.set && tmpStyle->stroke.isPaintserver()) { - SPPaintServer* server = tmpStyle->getStrokePaintServer(); + if (tmpStyle.stroke.set && tmpStyle.stroke.isPaintserver()) { + SPPaintServer* server = tmpStyle.getStrokePaintServer(); if ( SP_IS_GRADIENT(server) ) { SPGradient* target = 0; SPGradient* grad = SP_GRADIENT(server); @@ -1126,7 +1125,6 @@ void SwatchesPanel::_updateFromSelection() break; } } - sp_style_unref(tmpStyle); for ( boost::ptr_vector<ColorItem>::iterator it = docPalette->_colors.begin(); it != docPalette->_colors.end(); ++it ) { ColorItem* item = &*it; diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp index 229e82af4..a8be8b543 100644 --- a/src/ui/dialog/text-edit.cpp +++ b/src/ui/dialog/text-edit.cpp @@ -325,18 +325,18 @@ void TextEdit::onReadSelection ( gboolean dostyle, gboolean /*docontent*/ ) if (dostyle) { // create temporary style - SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT); + SPStyle query(SP_ACTIVE_DOCUMENT); // query style from desktop into it. This returns a result flag and fills query with the style of subselection, if any, or selection - //int result_fontspec = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONT_SPECIFICATION); - int result_family = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTFAMILY); - int result_style = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTSTYLE); - int result_numbers = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS); + //int result_fontspec = sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_FONT_SPECIFICATION); + int result_family = sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_FONTFAMILY); + int result_style = sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_FONTSTYLE); + int result_numbers = sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_FONTNUMBERS); // If querying returned nothing, read the style from the text tool prefs (default style for new texts) // (Ok to not get a font specification - must just rely on the family and style in that case) if (result_family == QUERY_STYLE_NOTHING || result_style == QUERY_STYLE_NOTHING || result_numbers == QUERY_STYLE_NOTHING) { - sp_style_read_from_prefs(query, "/tools/text"); + query.readFromPrefs("/tools/text"); } // FIXME: process result_family/style == QUERY_STYLE_MULTIPLE_DIFFERENT by showing "Many" in the lists @@ -351,40 +351,39 @@ void TextEdit::onReadSelection ( gboolean dostyle, gboolean /*docontent*/ ) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT); - double size = sp_style_css_size_px_to_units(query->font_size.computed, unit); + double size = sp_style_css_size_px_to_units(query.font_size.computed, unit); sp_font_selector_set_fontspec(fsel, fontspec, size ); setPreviewText (fontspec, phrase); - if (query->text_anchor.computed == SP_CSS_TEXT_ANCHOR_START) { - if (query->text_align.computed == SP_CSS_TEXT_ALIGN_JUSTIFY) { + if (query.text_anchor.computed == SP_CSS_TEXT_ANCHOR_START) { + if (query.text_align.computed == SP_CSS_TEXT_ALIGN_JUSTIFY) { align_justify.set_active(); } else { align_left.set_active(); } - } else if (query->text_anchor.computed == SP_CSS_TEXT_ANCHOR_MIDDLE) { + } else if (query.text_anchor.computed == SP_CSS_TEXT_ANCHOR_MIDDLE) { align_center.set_active(); } else { align_right.set_active(); } - if (query->writing_mode.computed == SP_CSS_WRITING_MODE_LR_TB) { + if (query.writing_mode.computed == SP_CSS_WRITING_MODE_LR_TB) { text_horizontal.set_active(); } else { text_vertical.set_active(); } double height; - if (query->line_height.normal) height = Inkscape::Text::Layout::LINE_HEIGHT_NORMAL; - else if (query->line_height.unit == SP_CSS_UNIT_PERCENT) - height = query->line_height.value; - else height = query->line_height.computed; + if (query.line_height.normal) height = Inkscape::Text::Layout::LINE_HEIGHT_NORMAL; + else if (query.line_height.unit == SP_CSS_UNIT_PERCENT) + height = query.line_height.value; + else height = query.line_height.computed; gchar *sstr = g_strdup_printf ("%d%%", (int) floor(height * 100 + 0.5)); gtk_entry_set_text ((GtkEntry *) gtk_bin_get_child ((GtkBin *) spacing_combo), sstr); g_free(sstr); - sp_style_unref(query); } blocked = false; } diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index c9fe37135..0f14d7534 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -247,11 +247,9 @@ static void spdc_apply_powerstroke_shape(const std::vector<Geom::Point> & points char const *style_str = NULL; style_str = repr->attribute("style"); if (style_str) { - SPStyle *style = sp_style_new(SP_ACTIVE_DOCUMENT); - sp_style_merge_from_style_string(style, style_str); - stroke_width = style->stroke_width.computed; - style->stroke_width.computed = 0; - sp_style_unref(style); + SPStyle style(SP_ACTIVE_DOCUMENT); + style.mergeString(style_str); + stroke_width = style.stroke_width.computed; } std::ostringstream s; @@ -821,14 +819,11 @@ void spdc_create_single_dot(ToolBase *ec, Geom::Point const &pt, char const *too // find out stroke width (TODO: is there an easier way??) double stroke_width = 3.0; - gchar const *style_str = NULL; - style_str = repr->attribute("style"); + gchar const *style_str = repr->attribute("style"); if (style_str) { - SPStyle *style = sp_style_new(SP_ACTIVE_DOCUMENT); - sp_style_merge_from_style_string(style, style_str); - stroke_width = style->stroke_width.computed; - style->stroke_width.computed = 0; - sp_style_unref(style); + SPStyle style(SP_ACTIVE_DOCUMENT); + style.mergeString(style_str); + stroke_width = style.stroke_width.computed; } // unset stroke and set fill color to former stroke color diff --git a/src/ui/widget/object-composite-settings.cpp b/src/ui/widget/object-composite-settings.cpp index 7439a402c..00a74c4fe 100644 --- a/src/ui/widget/object-composite-settings.cpp +++ b/src/ui/widget/object-composite-settings.cpp @@ -219,8 +219,8 @@ ObjectCompositeSettings::_subjectChanged() { return; _blocked = true; - SPStyle *query = sp_style_new (desktop->getDocument()); - int result = _subject->queryStyle(query, QUERY_STYLE_PROPERTY_MASTEROPACITY); + SPStyle query(desktop->getDocument()); + int result = _subject->queryStyle(&query, QUERY_STYLE_PROPERTY_MASTEROPACITY); switch (result) { case QUERY_STYLE_NOTHING: @@ -231,19 +231,19 @@ ObjectCompositeSettings::_subjectChanged() { case QUERY_STYLE_MULTIPLE_AVERAGED: // TODO: treat this slightly differently case QUERY_STYLE_MULTIPLE_SAME: _opacity_vbox.set_sensitive(true); - _opacity_scale.get_adjustment()->set_value(100 * SP_SCALE24_TO_FLOAT(query->opacity.value)); + _opacity_scale.get_adjustment()->set_value(100 * SP_SCALE24_TO_FLOAT(query.opacity.value)); break; } //query now for current filter mode and average blurring of selection - const int blend_result = _subject->queryStyle(query, QUERY_STYLE_PROPERTY_BLEND); + const int blend_result = _subject->queryStyle(&query, QUERY_STYLE_PROPERTY_BLEND); switch(blend_result) { case QUERY_STYLE_NOTHING: _fe_cb.set_sensitive(false); break; case QUERY_STYLE_SINGLE: case QUERY_STYLE_MULTIPLE_SAME: - _fe_cb.set_blend_mode(query->filter_blend_mode.value); + _fe_cb.set_blend_mode(query.filter_blend_mode.value); _fe_cb.set_sensitive(true); break; case QUERY_STYLE_MULTIPLE_DIFFERENT: @@ -253,7 +253,7 @@ ObjectCompositeSettings::_subjectChanged() { } if(blend_result == QUERY_STYLE_SINGLE || blend_result == QUERY_STYLE_MULTIPLE_SAME) { - int blur_result = _subject->queryStyle(query, QUERY_STYLE_PROPERTY_BLUR); + int blur_result = _subject->queryStyle(&query, QUERY_STYLE_PROPERTY_BLUR); switch (blur_result) { case QUERY_STYLE_NOTHING: //no blurring _fe_cb.set_blur_sensitive(false); @@ -266,7 +266,7 @@ ObjectCompositeSettings::_subjectChanged() { double perimeter = bbox->dimensions()[Geom::X] + bbox->dimensions()[Geom::Y]; // fixme: this is only half the perimeter, is that correct? _fe_cb.set_blur_sensitive(true); //update blur widget value - float radius = query->filter_gaussianBlur_deviation.value; + float radius = query.filter_gaussianBlur_deviation.value; float percent = radius * 400 / perimeter; // so that for a square, 100% == half side _fe_cb.set_blur_value(percent); } @@ -274,8 +274,6 @@ ObjectCompositeSettings::_subjectChanged() { } } - sp_style_unref(query); - _blocked = false; } diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 93b4893f2..1fc67dcef 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -977,7 +977,7 @@ SelectedStyle::update() return; // create temporary style - SPStyle *query = sp_style_new (_desktop->getDocument()); + SPStyle query(_desktop->getDocument()); for (int i = SS_FILL; i <= SS_STROKE; i++) { Gtk::EventBox *place = (i == SS_FILL)? &_fill_place : &_stroke_place; @@ -995,7 +995,7 @@ SelectedStyle::update() _popup_copy[i].set_sensitive(false); // query style from desktop. This returns a result flag and fills query with the style of subselection, if any, or selection - int result = sp_desktop_query_style (_desktop, query, + int result = sp_desktop_query_style (_desktop, &query, (i == SS_FILL)? QUERY_STYLE_PROPERTY_FILL : QUERY_STYLE_PROPERTY_STROKE); switch (result) { case QUERY_STYLE_NOTHING: @@ -1020,12 +1020,12 @@ SelectedStyle::update() } SPIPaint *paint; if (i == SS_FILL) { - paint = &(query->fill); + paint = &(query.fill); } else { - paint = &(query->stroke); + paint = &(query.stroke); } if (paint->set && paint->isPaintserver()) { - SPPaintServer *server = (i == SS_FILL)? SP_STYLE_FILL_SERVER (query) : SP_STYLE_STROKE_SERVER (query); + SPPaintServer *server = (i == SS_FILL)? SP_STYLE_FILL_SERVER (&query) : SP_STYLE_STROKE_SERVER (&query); if ( server ) { Inkscape::XML::Node *srepr = server->getRepr(); _paintserver_id[i] += "url(#"; @@ -1062,7 +1062,7 @@ SelectedStyle::update() } } else if (paint->set && paint->isColor()) { guint32 color = paint->value.color.toRGBA32( - SP_SCALE24_TO_FLOAT ((i == SS_FILL)? query->fill_opacity.value : query->stroke_opacity.value)); + SP_SCALE24_TO_FLOAT ((i == SS_FILL)? query.fill_opacity.value : query.stroke_opacity.value)); _lastselected[i] = _thisselected[i]; _thisselected[i] = color; // include opacity ((Inkscape::UI::Widget::ColorPreview*)_color_preview[i])->setRgba32 (color); @@ -1105,7 +1105,7 @@ SelectedStyle::update() clearTooltip(_opacity_place); clearTooltip(_opacity_sb); - int result = sp_desktop_query_style (_desktop, query, QUERY_STYLE_PROPERTY_MASTEROPACITY); + int result = sp_desktop_query_style (_desktop, &query, QUERY_STYLE_PROPERTY_MASTEROPACITY); switch (result) { case QUERY_STYLE_NOTHING: @@ -1122,16 +1122,16 @@ SelectedStyle::update() _opacity_blocked = true; _opacity_sb.set_sensitive(true); #if WITH_GTKMM_3_0 - _opacity_adjustment->set_value(SP_SCALE24_TO_FLOAT(query->opacity.value) * 100); + _opacity_adjustment->set_value(SP_SCALE24_TO_FLOAT(query.opacity.value) * 100); #else - _opacity_adjustment.set_value(SP_SCALE24_TO_FLOAT(query->opacity.value) * 100); + _opacity_adjustment.set_value(SP_SCALE24_TO_FLOAT(query.opacity.value) * 100); #endif _opacity_blocked = false; break; } // Now query stroke_width - int result_sw = sp_desktop_query_style (_desktop, query, QUERY_STYLE_PROPERTY_STROKEWIDTH); + int result_sw = sp_desktop_query_style (_desktop, &query, QUERY_STYLE_PROPERTY_STROKEWIDTH); switch (result_sw) { case QUERY_STYLE_NOTHING: _stroke_width.set_markup(""); @@ -1143,9 +1143,9 @@ SelectedStyle::update() { double w; if (_sw_unit) { - w = Inkscape::Util::Quantity::convert(query->stroke_width.computed, "px", _sw_unit); + w = Inkscape::Util::Quantity::convert(query.stroke_width.computed, "px", _sw_unit); } else { - w = query->stroke_width.computed; + w = query.stroke_width.computed; } current_stroke_width = w; @@ -1168,8 +1168,6 @@ SelectedStyle::update() default: break; } - - sp_style_unref(query); } void SelectedStyle::opacity_0(void) {_opacity_sb.set_value(0);} diff --git a/src/ui/widget/style-swatch.cpp b/src/ui/widget/style-swatch.cpp index 157fd2ad9..fa8543c46 100644 --- a/src/ui/widget/style-swatch.cpp +++ b/src/ui/widget/style-swatch.cpp @@ -260,13 +260,12 @@ void StyleSwatch::setStyle(SPCSSAttr *css) Glib::ustring css_string; sp_repr_css_write_string (_css, css_string); - SPStyle *temp_spstyle = sp_style_new(SP_ACTIVE_DOCUMENT); + + SPStyle style(SP_ACTIVE_DOCUMENT); if (!css_string.empty()) { - sp_style_merge_from_style_string (temp_spstyle, css_string.c_str()); + style.mergeString(css_string.c_str()); } - - setStyle (temp_spstyle); - sp_style_unref (temp_spstyle); + setStyle (&style); } void StyleSwatch::setStyle(SPStyle *query) |
