diff --git a/src/Gui/ExpressionCompleter.cpp b/src/Gui/ExpressionCompleter.cpp index 3a1bb3492b..bef42154df 100644 --- a/src/Gui/ExpressionCompleter.cpp +++ b/src/Gui/ExpressionCompleter.cpp @@ -820,9 +820,12 @@ void ExpressionCompleter::slotUpdate(const QString & prefix, int pos) std::transform(result.cbegin(), result.cend(), std::back_inserter(tokens), - [](const std::tuple& item) { + [&](const std::tuple& item) { return std::make_tuple( - get<0>(item), get<1>(item), QString::fromStdString(get<2>(item))); + get<0>(item), + QString::fromStdString(expr.toStdString().substr(0,get<1>(item))).size(), + QString::fromStdString(get<2>(item)) + ); }); return tokens; }; @@ -883,7 +886,9 @@ void ExpressionCompleter::slotUpdate(const QString & prefix, int pos) } // Not an unclosed string and the last character is a space - if (!stringing && !prefix.isEmpty() && prefix[prefixEnd-1] == QChar(32)) { + if (!stringing && !prefix.isEmpty() && + prefixEnd > 0 && prefixEnd <= prefix.size() && + prefix[prefixEnd-1] == QChar(32)) { if (auto itemView = popup()) itemView->setVisible(false); return; diff --git a/src/Gui/NotificationBox.cpp b/src/Gui/NotificationBox.cpp index 4a45cf0c6d..6f0bef9e44 100644 --- a/src/Gui/NotificationBox.cpp +++ b/src/Gui/NotificationBox.cpp @@ -180,7 +180,7 @@ void NotificationLabel::paintEvent(QPaintEvent *ev) { QStylePainter p(this); QStyleOptionFrame opt; - opt.init(this); + opt.initFrom(this); p.drawPrimitive(QStyle::PE_PanelTipLabel, opt); p.end(); QLabel::paintEvent(ev); @@ -191,7 +191,7 @@ void NotificationLabel::resizeEvent(QResizeEvent *e) QStyleHintReturnMask frameMask; QStyleOption option; - option.init(this); + option.initFrom(this); if (style()->styleHint(QStyle::SH_ToolTip_Mask, &option, this, &frameMask)) { setMask(frameMask.region);