summaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/selection-describer.cpp3
-rw-r--r--src/ui/dialog/selectordialog.cpp76
-rw-r--r--src/widgets/stroke-style.cpp18
3 files changed, 77 insertions, 20 deletions
diff --git a/src/selection-describer.cpp b/src/selection-describer.cpp
index b2b4b2d04..212ec9cf7 100644
--- a/src/selection-describer.cpp
+++ b/src/selection-describer.cpp
@@ -139,6 +139,9 @@ void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *select
// Parent name
SPObject *parent = item->parent;
+ if (!parent) { //fix selector * to "svg:svg"
+ return;
+ }
gchar const *parent_label = parent->getId();
gchar *parent_name = nullptr;
if (parent_label) {
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;
diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp
index 46454d508..5bd1b5d8d 100644
--- a/src/widgets/stroke-style.cpp
+++ b/src/widgets/stroke-style.cpp
@@ -951,15 +951,15 @@ StrokeStyle::updateLine()
return;
std::vector<SPItem*> const objects(sel->items().begin(), sel->items().end());
- SPObject * const object = objects[0];
- SPStyle * const style = object->style;
-
- /* Markers */
- updateAllMarkers(objects, true); // FIXME: make this desktop query too
-
- /* Dash */
- setDashSelectorFromStyle(dashSelector, style); // FIXME: make this desktop query too
-
+ if (objects.size()) {
+ SPObject * const object = objects[0];
+ SPStyle * const style = object->style;
+ /* Markers */
+ updateAllMarkers(objects, true); // FIXME: make this desktop query too
+
+ /* Dash */
+ setDashSelectorFromStyle(dashSelector, style); // FIXME: make this desktop query too
+ }
table->set_sensitive(true);
update = false;