Handle deleting logfile at program shutdown in core destructor

* Prevents order-of-destructor issues from losing the log filename before
  the core destructor uses it to delete the logfile.
This commit is contained in:
baldurk
2014-11-30 15:45:19 +00:00
parent e8f5e78811
commit c4f73c2b58
4 changed files with 9 additions and 13 deletions
-6
View File
@@ -256,12 +256,6 @@ void rdclog_filename(const char *filename)
logfile() = filename;
}
void rdclog_delete()
{
if(!logfile().empty())
FileIO::Delete(logfile().c_str());
}
void rdclog_flush()
{
}
-2
View File
@@ -140,11 +140,9 @@ void rdclog_int(LogType type, const char *file, unsigned int line, const char *f
const char *rdclog_getfilename();
void rdclog_filename(const char *filename);
void rdclog_delete();
#define RDCLOGFILE(fn) rdclog_filename(fn)
#define RDCGETLOGFILE() rdclog_getfilename()
#define RDCLOGDELETE() rdclog_delete()
#if ( !defined(RELEASE) || defined(FORCE_DEBUG_LOGS) ) && !defined(STRIP_DEBUG_LOGS)
#define RDCDEBUG(...) rdclog(RDCLog_Debug, __VA_ARGS__)
+7 -5
View File
@@ -203,20 +203,20 @@ void RenderDoc::Initialise()
// set default capture log - useful for when hooks aren't setup
// through the UI (and a log file isn't set manually)
{
string capture_filename, logging_filename;
string capture_filename;
const char *base = "RenderDoc_app";
if(IsReplayApp())
base = "RenderDoc_replay";
FileIO::GetDefaultFiles(base, capture_filename, logging_filename, m_Target);
FileIO::GetDefaultFiles(base, capture_filename, m_LoggingFilename, m_Target);
if(m_LogFile.empty())
SetLogFile(capture_filename.c_str());
string existingLog = RDCGETLOGFILE();
FileIO::Copy(existingLog.c_str(), logging_filename.c_str(), true);
RDCLOGFILE(logging_filename.c_str());
FileIO::Copy(existingLog.c_str(), m_LoggingFilename.c_str(), true);
RDCLOGFILE(m_LoggingFilename.c_str());
}
if(IsReplayApp())
@@ -262,6 +262,8 @@ RenderDoc::~RenderDoc()
RDCLOG("'Leaking' unretrieved capture %s", m_Captures[i].path.c_str());
}
}
FileIO::Delete(m_LoggingFilename.c_str());
m_RemoteServerThreadShutdown = true;
// don't join, just close the thread, as we can't wait while in the middle of module unloading
@@ -270,7 +272,7 @@ RenderDoc::~RenderDoc()
Network::Shutdown();
RDCLOGDELETE();
FileIO::Delete(m_LoggingFilename.c_str());
}
void RenderDoc::StartFrameCapture(void *wnd)
+2
View File
@@ -279,6 +279,8 @@ class RenderDoc
vector<KeyButton> m_FocusKeys;
vector<KeyButton> m_CaptureKeys;
string m_LoggingFilename;
string m_Target;
string m_LogFile;
string m_CurrentLogFile;