summaryrefslogtreecommitdiffstats
path: root/src/ui/dialog/styledialog.cpp
diff options
context:
space:
mode:
authorkamalpreetgrewal <grewalkamal005@gmail.com>2016-06-17 09:19:21 +0000
committerkamalpreetgrewal <grewalkamal005@gmail.com>2016-06-17 09:19:21 +0000
commit0ce1eb6fcfa054641be8225cf65ef7d01bf0a813 (patch)
treef85270d4fa63e8d1c4a7c4bae2109977ab05e50f /src/ui/dialog/styledialog.cpp
parentMerge changes from trunk (diff)
downloadinkscape-0ce1eb6fcfa054641be8225cf65ef7d01bf0a813.tar.gz
inkscape-0ce1eb6fcfa054641be8225cf65ef7d01bf0a813.zip
Fix a crash while deleting when there was single selector in the style dialog
(bzr r14949.1.23)
Diffstat (limited to 'src/ui/dialog/styledialog.cpp')
-rw-r--r--src/ui/dialog/styledialog.cpp43
1 files changed, 35 insertions, 8 deletions
diff --git a/src/ui/dialog/styledialog.cpp b/src/ui/dialog/styledialog.cpp
index 622bbcdb9..f81faec97 100644
--- a/src/ui/dialog/styledialog.cpp
+++ b/src/ui/dialog/styledialog.cpp
@@ -283,17 +283,44 @@ void StyleDialog::_delSelector()
Gtk::TreeModel::Row row = *iter;
path = _treeView.get_model()->get_path(iter);
int i = atoi(path.to_string().c_str());
- selVec.erase(selVec.begin()+i);
- _sValue.clear();
- for (unsigned i = 0; i < selVec.size(); ++i)
+ if (selVec.size() != 0)
{
- std::string selValue = (selVec[i].first + "{"
- + selVec[i].second + " }\n");
- _sValue.append(selValue.c_str());
- }
+ selVec.erase(selVec.begin()+i);
+ _sValue.clear();
+
+ if (selVec.size() != 0)
+ {
+ for (unsigned i = 0; i < selVec.size(); ++i)
+ {
+ std::string selValue = (selVec[i].first + "{"
+ + selVec[i].second + " }\n");
+ _sValue.append(selValue.c_str());
+ }
- _styleChild->firstChild()->setContent(_sValue.c_str());
+ }
+
+ /**
+ * Only if a value exists in _sValue and there is a _styleChild
+ * which contains the style element, then the content in style
+ * element is updated else the _styleChild is set and its content
+ * is set to an empty string.
+ */
+ if (!_sValue.empty() && _styleChild)
+ _styleChild->firstChild()->setContent(_sValue.c_str());
+ else
+ {
+ for ( unsigned i = 0; i < _num; ++i )
+ {
+ if ( std::string(_document->getReprRoot()->nthChild(i)->name())
+ == "svg:style" )
+ {
+ _styleChild = _document->getReprRoot()->nthChild(i);
+ }
+ }
+ _styleChild->firstChild()->setContent("");
+ }
+ }
_store->erase(row);
}
}