Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions hexrdgui/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import atexit
import gc
import os
import signal
import sys
Expand Down Expand Up @@ -70,5 +72,39 @@ def apply_parsed_args_to_hexrd_config(parsed_args):
setattr(hexrd_config, v, getattr(parsed_args, k))


def cleanup_widgets():
"""Clean up Qt widgets before Python shutdown

This is necessary for newer versions of Qt (>= 6.8),
because there are some kinds of conflicts between Qt and
the Python's cleanup systems that can cause crashes.

This fix ensures that all Qt objects are deleted and cleaned
up before Python performs its cleanup.
"""
app = QApplication.instance()
if app:
# Close all top-level widgets
for widget in app.topLevelWidgets()[:]:
try:
widget.close()
widget.deleteLater()
except RuntimeError:
# Already deleted by Qt - that's fine
pass

try:
# Process events to ensure deleteLater() is executed
app.processEvents()
except RuntimeError:
pass

# Force garbage collection
gc.collect()


# Register cleanup to run before Python's atexit handlers
atexit.register(cleanup_widgets)

if __name__ == '__main__':
main()
2 changes: 1 addition & 1 deletion hexrdgui/select_items_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def create_label(self, v):

def create_checkbox(self, v):
cb = QCheckBox(self.ui.table)
cb.setChecked(v)
cb.setChecked(bool(v))
cb.toggled.connect(self.checkbox_toggled)
self.checkboxes.append(cb)
return self.create_table_widget(cb)
Expand Down
Loading