File: repolish_run_on_direct_children.diff

package info (click to toggle)
qtbase-opensource-src 5.11.3%2Bdfsg1-1%2Bdeb10u5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 313,804 kB
  • sloc: cpp: 1,831,962; ansic: 318,856; xml: 113,585; python: 9,691; java: 7,209; asm: 4,023; perl: 2,151; sh: 1,790; yacc: 1,733; lex: 1,197; javascript: 469; makefile: 301; objc: 70
file content (23 lines) | stat: -rw-r--r-- 1,061 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Description: QStyleSheetStyle::repolish: only run on direct children
 When re-parenting, some widgets change their children. For example
 QLabel, when set to rich text, will not update, until receiving a polish
 call, at which time getting a list of all children recursively and then
 trying to call functions on them will crash, since the children change
 in the middle of this operation.
Origin: upstream, https://code.qt.io/cgit/qt/qtbase.git/commit/?id=21dcb96ddca357a6
Last-Update: 2019-09-06

--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -2878,7 +2878,10 @@ void QStyleSheetStyle::polish(QPalette &
 
 void QStyleSheetStyle::repolish(QWidget *w)
 {
-    QList<const QObject *> children = w->findChildren<const QObject *>(QString());
+    QList<const QObject *> children;
+    children.reserve(w->children().size() + 1);
+    for (auto child: qAsConst(w->children()))
+        children.append(child);
     children.append(w);
     styleSheetCaches->styleSheetCache.remove(w);
     updateObjects(children);