diff options
| author | Markus Engel <markus.engel@tum.de> | 2013-09-21 19:18:07 +0000 |
|---|---|---|
| committer | Markus Engel <markus.engel@tum.de> | 2013-09-21 19:18:07 +0000 |
| commit | 56dda4fb505028b68abac775b005cef65bce3477 (patch) | |
| tree | d96d176730c86cbd6415baff400df3a7ad7a2c02 | |
| parent | Fix preview page number for PDF Cairo import dialog (diff) | |
| download | inkscape-56dda4fb505028b68abac775b005cef65bce3477.tar.gz inkscape-56dda4fb505028b68abac775b005cef65bce3477.zip | |
Fixed segfault on copying text.
Fixed bugs:
- https://launchpad.net/bugs/1228509
(bzr r12569)
| -rw-r--r-- | src/selection-chemistry.cpp | 26 | ||||
| -rw-r--r-- | src/selection-chemistry.h | 2 | ||||
| -rw-r--r-- | src/text-context.cpp | 7 |
3 files changed, 22 insertions, 13 deletions
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 0cb7123ae..64ecd6e04 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -1104,18 +1104,21 @@ void sp_selection_cut(SPDesktop *desktop) * \pre item != NULL */ SPCSSAttr * -take_style_from_item(SPItem *item) +take_style_from_item(SPObject *object) { + // CPPIFY: + // This function should only take SPItems, but currently SPString is not an Item. + // write the complete cascaded style, context-free - SPCSSAttr *css = sp_css_attr_from_object(item, SP_STYLE_FLAG_ALWAYS); + SPCSSAttr *css = sp_css_attr_from_object(object, SP_STYLE_FLAG_ALWAYS); if (css == NULL) return NULL; - if ((SP_IS_GROUP(item) && item->children) || - (SP_IS_TEXT(item) && item->children && item->children->next == NULL)) { + if ((SP_IS_GROUP(object) && object->children) || + (SP_IS_TEXT(object) && object->children && object->children->next == NULL)) { // if this is a text with exactly one tspan child, merge the style of that tspan as well // If this is a group, merge the style of its topmost (last) child with style - for (SPObject *last_element = item->lastChild(); last_element != NULL; last_element = last_element->getPrev()) { + for (SPObject *last_element = object->lastChild(); last_element != NULL; last_element = last_element->getPrev()) { if ( last_element->style ) { SPCSSAttr *temp = sp_css_attr_from_object(last_element, SP_STYLE_FLAG_IFSET); if (temp) { @@ -1126,15 +1129,18 @@ take_style_from_item(SPItem *item) } } } - if (!(SP_IS_TEXT(item) || SP_IS_TSPAN(item) || SP_IS_TREF(item) || SP_IS_STRING(item))) { + + if (!(SP_IS_TEXT(object) || SP_IS_TSPAN(object) || SP_IS_TREF(object) || SP_IS_STRING(object))) { // do not copy text properties from non-text objects, it's confusing css = sp_css_attr_unset_text(css); } - // FIXME: also transform gradient/pattern fills, by forking? NO, this must be nondestructive - double ex = item->i2doc_affine().descrim(); - if (ex != 1.0) { - css = sp_css_attr_scale(css, ex); + if (SP_IS_ITEM(object)) { + // FIXME: also transform gradient/pattern fills, by forking? NO, this must be nondestructive + double ex = SP_ITEM(object)->i2doc_affine().descrim(); + if (ex != 1.0) { + css = sp_css_attr_scale(css, ex); + } } return css; diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h index f7a4f928c..e86000f70 100644 --- a/src/selection-chemistry.h +++ b/src/selection-chemistry.h @@ -85,7 +85,7 @@ void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *deskto void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop); void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *desktop); -SPCSSAttr *take_style_from_item (SPItem *item); +SPCSSAttr *take_style_from_item (SPObject *object); void sp_selection_cut(SPDesktop *desktop); void sp_selection_copy(SPDesktop *desktop); diff --git a/src/text-context.cpp b/src/text-context.cpp index 10973b7aa..f12ce6aa6 100644 --- a/src/text-context.cpp +++ b/src/text-context.cpp @@ -1390,8 +1390,11 @@ SPCSSAttr *sp_text_get_style_at_cursor(SPEventContext const *ec) return NULL; SPObject const *obj = sp_te_object_at_position(tc->text, tc->text_sel_end); - if (obj) - return take_style_from_item(SP_ITEM(obj)); + + if (obj) { + return take_style_from_item(const_cast<SPObject*>(obj)); + } + return NULL; } |
