Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
Crash on CB exit
Pecan:
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
--- Code: --- Manager::SetAppShuttingDown(true);
Manager::Get()->GetLogManager()->DebugLog(_T("Deinitializing plugins..."));
CodeBlocksEvent evtShutdown(cbEVT_APP_START_SHUTDOWN);
Manager::Get()->ProcessEvent(evtShutdown);
--- End code ---
but Manager.cpp:256 returns immediately because of
--- Code: ---bool Manager::ProcessEvent(CodeBlocksEvent& event)
{
if (IsAppShuttingDown())
return false;
--- End code ---
thus no plugin ever sees the event and no onRelease() is ever called.
I suggest manager.cpp:256 be changed to
--- Code: --- if (IsAppShuttingDown() and (event.GetEventType() != cbEVT_APP_START_SHUTDOWN))
return false;
--- End code ---
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:
Do you think this will fix ticket 1108?
https://sourceforge.net/p/codeblocks/tickets/1108/
Let me know if you think it will fix it and I will give it a go over the next few days and let you know how I go.
Pecan:
--- Quote from: AndrewCot on October 03, 2021, 02:55:21 am ---Do you think this will fix ticket 1108?
https://sourceforge.net/p/codeblocks/tickets/1108/
Let me know if you think it will fix it and I will give it a go over the next few days and let you know how I go.
--- End quote ---
Yes, that ticket is a perfect description of my experience.
By the way... Thank you for your work.
Pecan:
I no longer believe this is a proper fix for the problem.
I can still get that OnRelease() is never called on exit if I move the floating window around (or blink twice) .
OnRelease() is called in MainFrame::OnApplicationClose(wxCloseEvent& event) by the call to "Manager::Shutdown();", but the crash is happening way before at the "Hide();" statement;
ie., CB is attempting to Hide() the windows before OnRelease() is ever called.
That means plugins MUST close their floating windows on receiving the cbEVT_APP_START_SHUTDOWN event rather than OnRelease() .
There's some weird condition such that if you never touch a visible floating window, Hide() works ok. But if you ever move/resize/work-inside-of the window, Hide() crashes.
Pecan:
@ 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 .
--- Code: ---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();
--- End code ---
Navigation
[0] Message Index
[#] Next page
Go to full version