summaryrefslogtreecommitdiffstats
path: root/src/desktop-style.cpp
diff options
context:
space:
mode:
authorbulia byak <buliabyak@gmail.com>2006-05-23 23:00:56 +0000
committerbuliabyak <buliabyak@users.sourceforge.net>2006-05-23 23:00:56 +0000
commita487c804c6d0ffeb42111a5196a5ec378793a173 (patch)
treeb7b0df828bedb6f49b41588d8ae56b8d1ca0a5ed /src/desktop-style.cpp
parentremove default fill-opacity (diff)
downloadinkscape-a487c804c6d0ffeb42111a5196a5ec378793a173.tar.gz
inkscape-a487c804c6d0ffeb42111a5196a5ec378793a173.zip
fix crash when newly installed inkscape does not yet have last-set style
(bzr r988)
Diffstat (limited to 'src/desktop-style.cpp')
-rw-r--r--src/desktop-style.cpp50
1 files changed, 28 insertions, 22 deletions
diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp
index fa900600d..c9989df27 100644
--- a/src/desktop-style.cpp
+++ b/src/desktop-style.cpp
@@ -230,18 +230,20 @@ sp_desktop_get_master_opacity_tool(SPDesktop *desktop, char const *tool)
css = sp_desktop_get_style(desktop, true);
} else {
Inkscape::XML::Node *tool_repr = inkscape_get_repr(INKSCAPE, tool);
- css = sp_repr_css_attr_inherited(tool_repr, "style");
+ if (tool_repr) {
+ css = sp_repr_css_attr_inherited(tool_repr, "style");
+ }
}
- gchar const *property = css ? sp_repr_css_property(css, "opacity", "1.000") : 0;
+ if (css) {
+ gchar const *property = css ? sp_repr_css_property(css, "opacity", "1.000") : 0;
- if (desktop->current && property) { // if there is style and the property in it,
- if ( !sp_svg_number_read_f(property, &value) ) {
- value = 1.0; // things failed. set back to the default
+ if (desktop->current && property) { // if there is style and the property in it,
+ if ( !sp_svg_number_read_f(property, &value) ) {
+ value = 1.0; // things failed. set back to the default
+ }
}
- }
- if (css) {
sp_repr_css_attr_unref(css);
}
@@ -256,18 +258,20 @@ sp_desktop_get_opacity_tool(SPDesktop *desktop, char const *tool, bool is_fill)
css = sp_desktop_get_style(desktop, true);
} else {
Inkscape::XML::Node *tool_repr = inkscape_get_repr(INKSCAPE, tool);
- css = sp_repr_css_attr_inherited(tool_repr, "style");
+ if (tool_repr) {
+ css = sp_repr_css_attr_inherited(tool_repr, "style");
+ }
}
- gchar const *property = css ? sp_repr_css_property(css, is_fill ? "fill-opacity": "stroke-opacity", "1.000") : 0;
+ if (css) {
+ gchar const *property = css ? sp_repr_css_property(css, is_fill ? "fill-opacity": "stroke-opacity", "1.000") : 0;
- if (desktop->current && property) { // if there is style and the property in it,
- if ( !sp_svg_number_read_f(property, &value) ) {
- value = 1.0; // things failed. set back to the default
+ if (desktop->current && property) { // if there is style and the property in it,
+ if ( !sp_svg_number_read_f(property, &value) ) {
+ value = 1.0; // things failed. set back to the default
+ }
}
- }
- if (css) {
sp_repr_css_attr_unref(css);
}
@@ -282,19 +286,21 @@ sp_desktop_get_color_tool(SPDesktop *desktop, char const *tool, bool is_fill)
css = sp_desktop_get_style(desktop, true);
} else {
Inkscape::XML::Node *tool_repr = inkscape_get_repr(INKSCAPE, tool);
- css = sp_repr_css_attr_inherited(tool_repr, "style");
+ if (tool_repr) {
+ css = sp_repr_css_attr_inherited(tool_repr, "style");
+ }
}
- gchar const *property = sp_repr_css_property(css, is_fill ? "fill" : "stroke", "#000");
+ if (css) {
+ gchar const *property = sp_repr_css_property(css, is_fill ? "fill" : "stroke", "#000");
- if (desktop->current && property) { // if there is style and the property in it,
- if (strncmp(property, "url", 3)) { // and if it's not url,
- // read it
- r = sp_svg_read_color(property, r);
+ if (desktop->current && property) { // if there is style and the property in it,
+ if (strncmp(property, "url", 3)) { // and if it's not url,
+ // read it
+ r = sp_svg_read_color(property, r);
+ }
}
- }
- if (css) {
sp_repr_css_attr_unref(css);
}