mirror of
https://github.com/1dot13/source.git
synced 2026-08-05 14:00:23 +02:00
give the VFS log adapter static storage
sgp.cpp held two of these. One was a file-scope vfs::FileLogger* that was never assigned, whose only other mention was a delete in shutdown that could therefore never fire; it goes. The other is the adapter VFS actually logs through, which was a bare new that nothing freed. Make that one a function-local static rather than a scoped object. VFS keeps the bare pointer and still logs from the shutdown that atexit runs after WinMain has returned, so the adapter has to outlive the frame it is declared in. Constructing it before InitializeStandardGamingPlatform registers that handler is what puts its destructor after the handler rather than before it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
committed by
majcosta
co-authored by
Claude Opus 5
parent
86b23474cf
commit
d3cdcb52d2
+6
-5
@@ -22,7 +22,6 @@
|
||||
#include <vfs/Core/vfs.h>
|
||||
#include <vfs/Core/vfs_init.h>
|
||||
#include <vfs/Tools/vfs_log.h>
|
||||
#include <vfs/Tools/vfs_file_logger.h>
|
||||
#include "sgp_logger.h"
|
||||
#include "Text.h"
|
||||
#include "ExportStrings.h"
|
||||
@@ -52,7 +51,6 @@ static std::list<vfs::Path> vfs_config_ini;
|
||||
static bool s_DebugKeyboardInput = false;
|
||||
static vfs::Path s_CodePage;
|
||||
|
||||
static vfs::FileLogger *vfslog = NULL;
|
||||
|
||||
int iWindowedMode;
|
||||
|
||||
@@ -610,7 +608,6 @@ void ShutdownStandardGamingPlatform(void)
|
||||
|
||||
sgp::Logger::instance().shutdown();
|
||||
vfs::Log::flushDeleteAll();
|
||||
if(vfslog) delete vfslog;
|
||||
vfs::CVirtualFileSystem::shutdownVFS();
|
||||
vfs::ObjectAllocator::clear();
|
||||
}
|
||||
@@ -742,9 +739,13 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCommandL
|
||||
|
||||
sgp::Logger::instance().connectFile(VFS_LOG, L"vfs.log", false, sgp::Logger::FLUSH_ON_DELETE);
|
||||
|
||||
VfsLogAdapter* vfslog = new VfsLogAdapter(VFS_LOG);
|
||||
// Static, not a scoped object: VFS keeps the bare pointer and still logs from
|
||||
// the shutdown that atexit runs after WinMain has returned. Constructed here,
|
||||
// before InitializeStandardGamingPlatform registers that handler, so it is
|
||||
// destroyed after the handler has run rather than before it.
|
||||
static VfsLogAdapter vfslog(VFS_LOG);
|
||||
|
||||
vfs::Aspects::setLogger(vfslog, vfslog, vfslog, NULL /* vfslog */);
|
||||
vfs::Aspects::setLogger(&vfslog, &vfslog, &vfslog, NULL /* &vfslog */);
|
||||
|
||||
// Make sure that only one instance of this application is running at once
|
||||
// // Look for prev instance by searching for the window
|
||||
|
||||
Reference in New Issue
Block a user