Skip to content

Commit 5a664e4

Browse files
macevhiczMHendricks
authored andcommitted
hasTopLevelWidgets
1 parent 5ba0f29 commit 5a664e4

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

preditor/gui/app.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,15 @@ def root_window(cls):
117117
if root_window is None:
118118
windows = []
119119
dialogs = []
120-
for w in inst.topLevelWidgets():
121-
if w.parent() is None:
122-
if isinstance(w, QMainWindow):
123-
windows.append(w)
124-
elif isinstance(w, QDialog):
125-
dialogs.append(w)
120+
121+
hasTopLevelWidgets = hasattr(QApplication.instance(), "topLevelWidgets")
122+
if hasTopLevelWidgets:
123+
for w in inst.topLevelWidgets():
124+
if w.parent() is None:
125+
if isinstance(w, QMainWindow):
126+
windows.append(w)
127+
elif isinstance(w, QDialog):
128+
dialogs.append(w)
126129
if windows:
127130
root_window = windows[0]
128131
elif dialogs:

0 commit comments

Comments
 (0)