From 3e9296b964b8d0bd941991e05866882a689f4ac4 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 30 Sep 2017 18:15:54 +0200 Subject: Fix bug in comment #20 From Maren in bug #1715433. Clone original LPE can no longer be used to fill a powerstroke path --- src/live_effects/lpe-clone-original.cpp | 8 ++++---- src/live_effects/parameter/item.cpp | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-clone-original.cpp b/src/live_effects/lpe-clone-original.cpp index b035cc1d0..6e5ad66bf 100644 --- a/src/live_effects/lpe-clone-original.cpp +++ b/src/live_effects/lpe-clone-original.cpp @@ -181,7 +181,7 @@ LPECloneOriginal::cloneAttrbutes(SPObject *origin, SPObject *dest, const char * g_strfreev (styleattarray); Glib::ustring css_str; sp_repr_css_write_string(css_dest,css_str); - dest->getRepr()->setAttribute("style", css_str.c_str()); + dest->getRepr()->setAttribute("style", g_strdup(css_str.c_str())); } void @@ -189,9 +189,9 @@ LPECloneOriginal::doBeforeEffect (SPLPEItem const* lpeitem){ if (linkeditem.linksToItem()) { Glib::ustring attr = ""; if (method != CLM_NONE) { - attr.append("d,"); + attr += Glib::ustring("d,"); } - attr.append(Glib::ustring(attributes.param_getSVGValue()).append(",")); + attr += Glib::ustring(attributes.param_getSVGValue()) + Glib::ustring(","); if (attr.size() && !Glib::ustring(attributes.param_getSVGValue()).size()) { attr.erase (attr.size()-1, 1); } @@ -199,7 +199,7 @@ LPECloneOriginal::doBeforeEffect (SPLPEItem const* lpeitem){ if (style_attr.size() && !Glib::ustring(style_attributes.param_getSVGValue()).size()) { style_attr.erase (style_attr.size()-1, 1); } - style_attr.append(Glib::ustring(style_attributes.param_getSVGValue()).append(",")); + style_attr += Glib::ustring(style_attributes.param_getSVGValue()) + Glib::ustring(","); SPItem * origin = SP_ITEM(linkeditem.getObject()); SPItem * dest = SP_ITEM(sp_lpe_item); diff --git a/src/live_effects/parameter/item.cpp b/src/live_effects/parameter/item.cpp index 149fd6627..e075cab1a 100644 --- a/src/live_effects/parameter/item.cpp +++ b/src/live_effects/parameter/item.cpp @@ -101,7 +101,10 @@ ItemParam::param_readSVGValue(const gchar * strvalue) gchar * ItemParam::param_getSVGValue() const { - return g_strdup(href); + if (href) { + return g_strdup(href); + } + return g_strdup(""); } gchar * -- cgit v1.2.3 From 0f5574afd93303c82c1ae34fd1c59791c4d81217 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 30 Sep 2017 18:47:13 +0200 Subject: Fix bug #1719505 segfault on convert to path --- src/path-chemistry.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index 7840c4ca8..6c4b67bef 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -368,7 +368,12 @@ sp_item_list_to_curves(const std::vector &items, std::vector& { continue; } - + //TODO: decide if we want to unlink clones or not, for now keep previous functionality retaining clones as is + SPUse *use = dynamic_cast(item); + if (use) { + continue; + } + SPPath *path = dynamic_cast(item); if (path && !path->_curve_before_lpe) { // remove connector attributes -- cgit v1.2.3 From 1fe5b815e10ade11fbb4bbec6b15f1a8945b7a1b Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sat, 30 Sep 2017 16:46:21 +0200 Subject: Do not crash if raster image can not be opened by ImageMagick The crash only affected embedded images. (we were already catching the exception when loading a linked file) While at it add some error reporting via debug messages, fix a memory leak and do some minor cleanup. Fixed bug: - https://bugs.launchpad.net/inkscape/+bug/1720330 --- src/extension/internal/bitmap/imagemagick.cpp | 32 +++++++++++++++++---------- 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/extension/internal/bitmap/imagemagick.cpp b/src/extension/internal/bitmap/imagemagick.cpp index cc5b3d1bc..352271e26 100644 --- a/src/extension/internal/bitmap/imagemagick.cpp +++ b/src/extension/internal/bitmap/imagemagick.cpp @@ -39,7 +39,7 @@ namespace Bitmap { class ImageMagickDocCache: public Inkscape::Extension::Implementation::ImplementationDocumentCache { friend class ImageMagick; private: - void readImage(char const *xlink, Magick::Image *image); + void readImage(char const *xlink, char const *id, Magick::Image *image); protected: Inkscape::XML::Node** _nodes; @@ -85,11 +85,12 @@ ImageMagickDocCache::ImageMagickDocCache(Inkscape::UI::View::View * view) : { _nodes[_imageCount] = node; char const *xlink = node->attribute("xlink:href"); + char const *id = node->attribute("id"); _originals[_imageCount] = xlink; _caches[_imageCount] = (char*)""; _cacheLengths[_imageCount] = 0; _images[_imageCount] = new Magick::Image(); - readImage(xlink, _images[_imageCount]); + readImage(xlink, id, _images[_imageCount]); _imageItems[_imageCount] = item; _imageCount++; } @@ -113,26 +114,33 @@ ImageMagickDocCache::~ImageMagickDocCache ( ) { } void -ImageMagickDocCache::readImage(const char *xlink, Magick::Image *image) +ImageMagickDocCache::readImage(const char *xlink, const char *id, Magick::Image *image) { // Find if the xlink:href is base64 data, i.e. if the image is embedded - char *search = (char *) g_strndup(xlink, 30); + gchar *search = g_strndup(xlink, 30); if (strstr(search, "base64") != (char*)NULL) { // 7 = strlen("base64") + strlen(",") const char* pureBase64 = strstr(xlink, "base64") + 7; Magick::Blob blob; blob.base64(pureBase64); - image->read(blob); - } - else { - const gchar *path = xlink; - if (strncmp (xlink,"file:", 5) == 0) { - path = g_filename_from_uri(xlink, NULL, NULL); + try { + image->read(blob); + } catch (Magick::Exception &error_) { + g_warning("ImageMagick could not read '%s'\nDetails: %s", id, error_.what()); + } + } else { + gchar *path; + if (strncmp (xlink,"file:", 5) == 0) { + path = g_filename_from_uri(xlink, NULL, NULL); + } else { + path = g_strdup(xlink); } - try { image->read(path); - } catch (...) {} + } catch (Magick::Exception &error_) { + g_warning("ImageMagick could not read '%s' from '%s'\nDetails: %s", id, path, error_.what()); + } + g_free(path); } g_free(search); } -- cgit v1.2.3 From 6d91668aef6c3bcf4bfe247de1f58ba4b11cf367 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sun, 1 Oct 2017 13:12:42 +0200 Subject: Add button to apply on path parameter as suggest Maren in bug #1715433#23 --- src/live_effects/parameter/text.cpp | 24 ++++++++++++++++++++---- src/live_effects/parameter/text.h | 1 + 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/live_effects/parameter/text.cpp b/src/live_effects/parameter/text.cpp index 3f41bfeed..7e56b2c75 100644 --- a/src/live_effects/parameter/text.cpp +++ b/src/live_effects/parameter/text.cpp @@ -9,7 +9,7 @@ */ #include "ui/widget/registered-widget.h" -#include +#include #include "live_effects/parameter/text.h" #include "live_effects/effect.h" @@ -18,9 +18,10 @@ #include "inkscape.h" #include "verbs.h" #include "display/canvas-text.h" - #include <2geom/sbasis-geometric.h> +#include + namespace Inkscape { namespace LivePathEffect { @@ -124,6 +125,14 @@ TextParam::param_getDefaultSVGValue() const return str; } +void +TextParam::setTextParam(Inkscape::UI::Widget::RegisteredText *rsu) +{ + Glib::ustring str(rsu->getText()); + param_setValue(str); + write_to_SVG(); +} + Gtk::Widget * TextParam::param_newWidget() { @@ -131,9 +140,16 @@ TextParam::param_newWidget() param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc())); rsu->setText(value); rsu->setProgrammatically = false; - rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change text parameter")); - return dynamic_cast (rsu); + Gtk::Box *text_container = Gtk::manage(new Gtk::Box()); + Gtk::Button *set = Gtk::manage(new Gtk::Button(Glib::ustring("✔"))); + set->signal_clicked() + .connect(sigc::bind(sigc::mem_fun(*this, &TextParam::setTextParam),rsu)); + text_container->pack_start(*rsu, false, false, 2); + text_container->pack_start(*set, false, false, 2); + Gtk::Widget *return_widg = dynamic_cast (text_container); + return_widg->set_halign(Gtk::ALIGN_END); + return return_widg; } void diff --git a/src/live_effects/parameter/text.h b/src/live_effects/parameter/text.h index 460ef8629..a9de26a52 100644 --- a/src/live_effects/parameter/text.h +++ b/src/live_effects/parameter/text.h @@ -42,6 +42,7 @@ public: void param_setValue(Glib::ustring newvalue); void param_hide_canvas_text(); + void setTextParam(Inkscape::UI::Widget::RegisteredText *rsu); virtual void param_set_default(); virtual void param_update_default(const gchar * default_value); void setPos(Geom::Point pos); -- cgit v1.2.3 From ad03eb3eed2ad07c086fea71326c56701f3cf6e1 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sun, 1 Oct 2017 15:05:59 +0200 Subject: A little styling tweak to a LPE expander --- src/live_effects/effect.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 703852881..2332ab8f2 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -874,7 +874,8 @@ Effect::defaultParamSet() vbox->pack_start(*dynamic_cast (expander), true, true, 2); if (has_params) { Gtk::Widget *vboxwidg = dynamic_cast(vbox); - vboxwidg->set_margin_bottom(15); + vboxwidg->set_margin_bottom(10); + vboxwidg->set_margin_top(5); return vboxwidg; } else { return NULL; -- cgit v1.2.3