fix(macos): persist list-control settings on Dock → Quit - #141
Merged
Conversation
CMuleListCtrl::SaveSettings runs from the destructor. On the CMD+Q and red-X close paths the wx main loop naturally drains its pending- delete queue (where amuledlg->Destroy() puts the frame) before returning to CamuleApp::OnExit, so the destructor chain runs against a live wxConfig and column widths / sort orders persist. The macOS Dock right-click → Quit path skips that drain: CamuleGuiApp::OnEndSession calls OnExit() directly, which then deletes wxConfig (line 263) and, on macOS, std::_Exit(0) past every static destructor (line 419). The CamuleDlg pending-Destroy is never processed, so no list-control destructor ever fires and persisted state is silently lost. Reported on macOS with the Downloads list. Drain the pending-delete queue at the top of CamuleApp::OnExit, before tearing down wxConfig. Frame + child destructors now run with a live config on every quit path; CMD+Q and red-X are unaffected (the queue is already empty by the time OnExit runs).
got3nks
added a commit
that referenced
this pull request
Jul 4, 2026
…#290) CMuleListCtrl::SaveSettings runs from the frame's destructor, which CamuleDlg::OnClose -> CamuleRemoteGuiApp::ShutDown only schedules (amuledlg->Destroy(), lazy). CamuleRemoteGuiApp::OnExit then std::_Exit(0)s to dodge the wxWebSession dtor crash, which skips wx's own cleanup, so the queued destroy and the wxConfig flush never happen and freshly-resized column widths / sort orders are silently lost. Cmd+Q happened to drain the queue naturally, which is why only that path persisted. Two fixes, mirroring the monolithic app: - OnExit: DeletePendingObjects() + tear down wxConfig (which flushes it) before _Exit(0), so the red-X + confirm path runs the list-control destructors against a live config. Mirrors CamuleApp::OnExit (#141). - OnQueryEndSession / OnEndSession handlers: the macOS Dock right-click -> Quit path ends the session without going through OnExit, so route it through ShutDown + OnExit explicitly. Mirrors CamuleGuiApp (amule-gui.cpp).
Cflsft
pushed a commit
to Cflsft/amule
that referenced
this pull request
Jul 6, 2026
…amule-org#290) CMuleListCtrl::SaveSettings runs from the frame's destructor, which CamuleDlg::OnClose -> CamuleRemoteGuiApp::ShutDown only schedules (amuledlg->Destroy(), lazy). CamuleRemoteGuiApp::OnExit then std::_Exit(0)s to dodge the wxWebSession dtor crash, which skips wx's own cleanup, so the queued destroy and the wxConfig flush never happen and freshly-resized column widths / sort orders are silently lost. Cmd+Q happened to drain the queue naturally, which is why only that path persisted. Two fixes, mirroring the monolithic app: - OnExit: DeletePendingObjects() + tear down wxConfig (which flushes it) before _Exit(0), so the red-X + confirm path runs the list-control destructors against a live config. Mirrors CamuleApp::OnExit (amule-org#141). - OnQueryEndSession / OnEndSession handlers: the macOS Dock right-click -> Quit path ends the session without going through OnExit, so route it through ShutDown + OnExit explicitly. Mirrors CamuleGuiApp (amule-gui.cpp).
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.
Summary
On macOS, quitting aMule via the Dock right-click → Quit silently lost all list-control persisted state — column widths, sort orders, hidden-column choices on Downloads / Search / Server lists. CMD+Q and the red-X close button both worked. Reported in passing while testing column widths on the Downloads list.
Root cause
CMuleListCtrl::SaveSettingsis called from the destructor. The destructor chain only runs if the wx main loop drains its pending-delete queue (which is whereCamuleGuiApp::ShutDownputs the main frame viaamuledlg->Destroy()— that call is lazy, scheduling deletion on the loop tail rather than running it inline).OnClosereturns and naturally processes the pending-delete queue beforeCamuleApp::OnExitruns →CamuleDlgand its child list controls destruct with a livewxConfig→SaveSettingswrites correctly.CamuleGuiApp::OnEndSessioncallsOnExit()directly.CamuleApp::OnExitat amule.cpp:263 deleteswxConfigimmediately, then at amule.cpp:419 callsstd::_Exit(0)which bypasses static destructors. The pending-delete queue is never processed →CamuleDlgdestructor never runs →CMuleListCtrl::SaveSettingsnever fires.Fix
Drain the pending-delete queue (
DeletePendingObjects()) at the top ofCamuleApp::OnExit, before thewxConfigteardown. The frame + child destructor chain now runs with a live config on every quit path. CMD+Q and red-X are unaffected — the pending queue is already empty by the timeOnExitruns on those paths, soDeletePendingObjects()is a no-op.Test plan