summaryrefslogtreecommitdiffstats
path: root/src/ui/dialog/selectordialog.cpp
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2019-04-27 11:00:40 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2019-04-27 11:00:40 +0000
commit73f1400782111f705fdbcd974f7477cce96b46bc (patch)
treeea2e5431a0fe6f04991ad84f8289c7b154a19c3d /src/ui/dialog/selectordialog.cpp
parentAdd out of bound checks to fill bucket (diff)
downloadinkscape-73f1400782111f705fdbcd974f7477cce96b46bc.tar.gz
inkscape-73f1400782111f705fdbcd974f7477cce96b46bc.zip
Fixes some crashes when selector is * and allow select multiple tags
Diffstat (limited to 'src/ui/dialog/selectordialog.cpp')
-rw-r--r--src/ui/dialog/selectordialog.cpp76
1 files changed, 65 insertions, 11 deletions
diff --git a/src/ui/dialog/selectordialog.cpp b/src/ui/dialog/selectordialog.cpp
index d2361a775..b4977d0ee 100644
--- a/src/ui/dialog/selectordialog.cpp
+++ b/src/ui/dialog/selectordialog.cpp
@@ -457,7 +457,14 @@ void SelectorDialog::_readStyleElement()
coltype colType = SELECTOR;
for (auto tok : tokensplus) {
REMOVE_SPACES(tok);
- if (tok.find(" ") != -1 || tok.erase(0, 1).find(".") != -1) {
+ if (SPAttributeRelSVG::isSVGElement(tok) ||
+ tok.find(" ") != -1 ||
+ tok[0] == '>' ||
+ tok[0] == '+' ||
+ tok[0] == '~' ||
+ tok[0] == '*' ||
+ tok.erase(0, 1).find(".") != -1)
+ {
colType = UNHANDLED;
}
}
@@ -794,7 +801,14 @@ std::vector<SPObject *> SelectorDialog::_getObjVec(Glib::ustring selector) {
bool unhandled = false;
for (auto tok : tokensplus) {
REMOVE_SPACES(tok);
- if (tok.find(" ") != -1 || tok.erase(0, 1).find(".") != -1) {
+ if (SPAttributeRelSVG::isSVGElement(tok) ||
+ tok.find(" ") != -1 ||
+ tok[0] == '>' ||
+ tok[0] == '+' ||
+ tok[0] == '~' ||
+ tok[0] == '*' ||
+ tok.erase(0, 1).find(".") != -1)
+ {
unhandled = true;
std::vector<SPObject *> objVecSplited = SP_ACTIVE_DOCUMENT->getObjectsBySelector(tok);
objVec.insert(objVec.end(), objVecSplited.begin(), objVecSplited.end());
@@ -956,17 +970,57 @@ void SelectorDialog::_addSelector()
* set to ".Class1"
*/
selectorValue = textEditPtr->get_text();
- Glib::ustring firstWord = selectorValue.substr(0, selectorValue.find_first_of(" >+~"));
- if (firstWord != selectorValue) {
- handled = false;
- }
+
del->set_sensitive(true);
-
- if (selectorValue[0] == '.' || selectorValue[0] == '#' || selectorValue[0] == '*' ||
- SPAttributeRelSVG::isSVGElement(selectorValue)) {
- invalid = false;
- } else {
+ std::vector<Glib::ustring> tokensplus = Glib::Regex::split_simple("[,]+", selectorValue);
+ bool unhandled = false;
+ bool partialinvalid = false;
+ for (auto tok : tokensplus) {
+ REMOVE_SPACES(tok);
+ if (SPAttributeRelSVG::isSVGElement(tok) ||
+ tok.find(" ") != -1 ||
+ tok[0] == '>' ||
+ tok[0] == '+' ||
+ tok[0] == '~' ||
+ tok[0] == '*' ||
+ tok.erase(0, 1).find(".") != -1)
+ {
+ unhandled = true;
+ Glib::ustring firstWord = tok.substr(0, tok.find_first_of(" >+~"));
+ if (firstWord != tok) {
+ handled = false;
+ }
+
+ if (!partialinvalid &&
+ (tok[0] == '.' ||
+ tok[0] == '#' ||
+ tok[0] == '*' ||
+ SPAttributeRelSVG::isSVGElement(tok)))
+ {
+ partialinvalid = false;
+ } else {
+ partialinvalid = true;
+ }
+ }
+ }
+ if (!unhandled) {
+ Glib::ustring firstWord = selectorValue.substr(0, selectorValue.find_first_of(" >+~"));
+ if (firstWord != selectorValue) {
+ handled = false;
+ }
+ if (selectorValue[0] == '.' ||
+ selectorValue[0] == '#' ||
+ selectorValue[0] == '*' ||
+ SPAttributeRelSVG::isSVGElement(selectorValue))
+ {
+ invalid = false;
+ } else {
+ textLabelPtr->show();
+ }
+ } else if(partialinvalid) {
textLabelPtr->show();
+ } else {
+ invalid = false;
}
}
delete textDialogPtr;