Cleaner closing#89
Open
krish-vj wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Description: Fix Simulator Window Transition Hangs, C++ Object Deletion Crashes, and Windows Console Unicode Errors
Summary
This PR addresses several critical stability issues occurring when transitioning from the simulator/flowsheet workspace back to the landing page, as well as console encoding crashes on Windows platforms.
Identified Issues & Root Causes
1. "Not Responding" / Abrupt Freezes on Window Transition
deleteLater()on theMainAppinstance. BecauseMainAppowns complex sub-components, dock widgets, simulation threads, and scene items, callingdeleteLater()schedules asynchronous C++ destruction. This destruction races with the Qt event loop. When the landing page restores, repaints, and handles focus, it triggers queries or events on objects whose C++ counterparts have already been deleted, resulting in Windows "Not Responding" hangs or abrupt segmentation faults.2. Cursor Stack Pollution & Corrupted Interaction
WaitCursororPointingHandCursor) set during simulation execution or drag-and-drop operations were not fully drained from Qt's cursor stack upon window closure. The polluted cursor stack caused mouse-tracking and hover events to fail on the restored Landing Page, making it seem locked or unresponsive.3. Unicode Console Encoding Crashes on Windows
print()statements inContainer.pyandundo_manager.pyused the unicode right-arrow character→. On Windows machines running standard non-UTF-8 console codepages (e.g. CP1252), this caused uncaughtUnicodeEncodeErrorexceptions, causing background routines to crash.Solutions & Implementation Details
1. Safe Window Stashing (No
deleteLater())MainAppwindow and stash it in a module-level list_stashed_windowsinstead of deleting it. Keeping the window alive but hidden completely bypasses C++ destruction issues and races, with negligible memory impact.closeEventmonkey-patching wrapper with a standard PyQtclosedsignal connection.2. Robust Thread & Cursor Cleanup
closeEventin mainApp.py that:self.thrd).closedsignal and accepts the event.restore_landing_pagemethod to ensure a clean cursor stack state before showing the landing page.try-except RuntimeErrorguards in dock widget cleanup to handle instances where underlying C++ objects may have been freed elsewhere.3. ASCII Arrow Replacements for Console Prints
→characters with ASCII->in Container.py and undo_manager.py.