From 91d553139d5ee0e3ec9f25f3665014b169109fce Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Wed, 22 Feb 2023 21:29:39 -0600 Subject: [PATCH 1/2] Gui: Fix use of undocumented init() function --- src/Gui/NotificationBox.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); From 5bf522ebcfe86684b592756adaf8b7cdd9291e5e Mon Sep 17 00:00:00 2001 From: 0penBrain <48731257+0penBrain@users.noreply.github.com> Date: Mon, 20 Feb 2023 19:06:45 +0100 Subject: [PATCH 2/2] [Bugfix] Gui: fix bug in expression completer tokenizing, fixes #8590 --- src/Gui/ExpressionCompleter.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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;