diff options
| author | kamalpreetgrewal <grewalkamal005@gmail.com> | 2016-06-13 08:01:06 +0000 |
|---|---|---|
| committer | kamalpreetgrewal <grewalkamal005@gmail.com> | 2016-06-13 08:01:06 +0000 |
| commit | d35fb3b6e570691908282543b97076591510c5f3 (patch) | |
| tree | 649dcea2491952f2a40ff99a0ad2e8152818f5af /src | |
| parent | Correct parsing of style element (diff) | |
| download | inkscape-d35fb3b6e570691908282543b97076591510c5f3.tar.gz inkscape-d35fb3b6e570691908282543b97076591510c5f3.zip | |
Fix crash when object without style attribute is added to selector
(bzr r14949.1.15)
Diffstat (limited to 'src')
| -rw-r--r-- | src/ui/dialog/styledialog.cpp | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/ui/dialog/styledialog.cpp b/src/ui/dialog/styledialog.cpp index 9abcc1562..997d8b230 100644 --- a/src/ui/dialog/styledialog.cpp +++ b/src/ui/dialog/styledialog.cpp @@ -173,21 +173,28 @@ void StyleDialog::_addSelector() for ( unsigned i = 0; i < selected.size(); ++i ) { SPObject *obj = selected.at(i); - std::string style = std::string(obj->getRepr()->attribute("style")); - style = row[_mColumns._selectorLabel] + ";" + style; - - for ( List<AttributeRecord const> iter = obj->getRepr()->attributeList(); - iter; ++iter ) { - gchar const * property = g_quark_to_string(iter->key); - gchar const * value = iter->value; - - if ( std::string(property) == "style" ) - { - selectorValue = "\n" + row[_mColumns._selectorLabel] + "{" - + std::string(value) + "}"; + if (obj->getRepr()->attribute("style")) + { + std::string style = std::string(obj->getRepr()->attribute("style")); + style = row[_mColumns._selectorLabel] + ";" + style; + + for ( List<AttributeRecord const> iter = obj->getRepr()->attributeList(); + iter; ++iter ) { + gchar const * property = g_quark_to_string(iter->key); + gchar const * value = iter->value; + + if ( std::string(property) == "style" ) + { + selectorValue = "\n" + row[_mColumns._selectorLabel] + "{" + + std::string(value) + "}"; + } } } + else + std::cout << "This object does not have a style attribute. Add " + "one first."; + /** * @brief root * A new style element is added to the document with value obtained |
