Skip to content

Commit 84a5ea5

Browse files
committed
"Fixed" a crash when "exit" is being used to shutdown the server on Windows
Moreover, the model cache notifier is now restored before Python is shutdown.
1 parent de11ddb commit 84a5ea5

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/core/sp_main.cpp

+12-3
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@
6161
#include "modules/entities/entities_entity.h"
6262
#include "modules/core/core.h"
6363

64+
#ifdef _WIN32
65+
#include "Windows.h"
66+
#endif
67+
6468

6569
//-----------------------------------------------------------------------------
6670
// Disable warnings.
@@ -374,6 +378,9 @@ void CSourcePython::Unload( void )
374378
DevMsg(1, MSG_PREFIX "Restoring old logging state...\n");
375379
LoggingSystem_PopLoggingState(false);
376380
#endif
381+
382+
DevMsg(1, MSG_PREFIX "Resetting cache notifier...\n");
383+
modelcache->SetCacheNotify(m_pOldMDLCacheNotifier);
377384

378385
DevMsg(1, MSG_PREFIX "Shutting down python...\n");
379386
g_PythonManager.Shutdown();
@@ -396,10 +403,12 @@ void CSourcePython::Unload( void )
396403
DisconnectTier1Libraries( );
397404
#endif
398405

399-
DevMsg(1, MSG_PREFIX "Resetting cache notifier...\n");
400-
modelcache->SetCacheNotify(m_pOldMDLCacheNotifier);
401-
402406
Msg(MSG_PREFIX "Unloaded successfully.\n");
407+
408+
#ifdef _WIN32
409+
// This "fixes" a crash after SP has been unloaded.
410+
Sleep(1000);
411+
#endif
403412
}
404413

405414
//-----------------------------------------------------------------------------

0 commit comments

Comments
 (0)