CB (on Windows) is crashing when exited when any plugin is dependent on its OnRelease() call to exit properly. Especially when there are floating windows open.
This happens because:
Main.cpp 3099 issues
Manager::SetAppShuttingDown(true);
Manager::Get()->GetLogManager()->DebugLog(_T("Deinitializing plugins..."));
CodeBlocksEvent evtShutdown(cbEVT_APP_START_SHUTDOWN);
Manager::Get()->ProcessEvent(evtShutdown);
but Manager.cpp:256 returns immediately because of
bool Manager::ProcessEvent(CodeBlocksEvent& event)
{
if (IsAppShuttingDown())
return false;
thus no plugin ever sees the event and no onRelease() is ever called.
I suggest manager.cpp:256 be changed to
if (IsAppShuttingDown() and (event.GetEventType() != cbEVT_APP_START_SHUTDOWN))
return false;
My tests show this mod works.
To experience the crash, set CodeCompletions Symbols window to floating.
Pull the winidow outside CB's main window. Resize it. Now close CB.
@ AndrewCot
After a full day and a half, I think I've finally found a fix for these crashes.
Try this patch.
The result is that (on Windows):
1)Hide() cannot be called when there are shown/floating windows. It hangs.
2) And shown/floating windows must be closed before calling Manager::Shutdown(); else it crashes.
This fixes my floating Symbols window crash and also fixes Bug #1108 .
Index: src/src/main.cpp
===================================================================
--- src/src/main.cpp (revision 12516)
+++ src/src/main.cpp (working copy)
@@ -3096,6 +3096,7 @@
Manager::SetAppShuttingDown(true);
+ // This does not call OnRelease() for the plugins. It's just a notify...
Manager::Get()->GetLogManager()->DebugLog(_T("Deinitializing plugins..."));
CodeBlocksEvent evtShutdown(cbEVT_APP_START_SHUTDOWN);
Manager::Get()->ProcessEvent(evtShutdown);
@@ -3117,8 +3118,19 @@
while (GetEventHandler() != this)
PopEventHandler(false);
+ #if defined ( __WIN32__ ) || defined ( _WIN64 )
+ // Hide() causes crashes and hangs on windows when floating windows are shown //(ph 2021/10/4)
// Hide the window
+ //-Hide();
+ // Move the window off the screen instead of Hide()
+ wxDisplay display(wxDisplay::GetFromWindow(this));
+ wxRect screen = display.GetClientArea();
+ wxWindow* pWindow = Manager::Get()->GetAppWindow();
+ pWindow->Move(screen.GetX()+screen.GetWidth(), screen.GetY());
+ #else
+ // Hide the window
Hide();
+ #endif
if (!Manager::IsBatchBuild())
{
@@ -3139,6 +3151,17 @@
}
}
+ #if defined ( __WIN32__ ) || defined ( _WIN64 )
+ // Close shown floating windows before shutdown or get occasional crashes
+ wxAuiPaneInfoArray& all_panes = m_LayoutManager.GetAllPanes();
+ for(size_t ii = 0; ii < all_panes.Count(); ++ii)
+ {
+ wxAuiPaneInfo paneInfo = all_panes[ii];
+ if (paneInfo.IsShown() and paneInfo.IsFloating())
+ m_LayoutManager.ClosePane(paneInfo);
+ }
+ #endif
+
Manager::Shutdown(); // Shutdown() is not Free(), Manager is automatically destroyed at exit
Destroy();