Be paranoid about g_system being set
svn-id: r36131
This commit is contained in:
parent
164a099c7f
commit
7eaafd933f
6 changed files with 16 additions and 8 deletions
|
@ -460,6 +460,7 @@ void SearchManager::clear() {
|
|||
// Always keep system specific archives in the SearchManager.
|
||||
// But we give them a lower priority than the default priority (which is 0),
|
||||
// so that archives added by client code are searched first.
|
||||
if (g_system)
|
||||
g_system->addSysArchivesToSearchSet(*this, -1);
|
||||
|
||||
// Add the current dir as a very last resort.
|
||||
|
|
|
@ -65,9 +65,11 @@ bool ConfigFile::loadFromFile(const String &filename) {
|
|||
}
|
||||
|
||||
bool ConfigFile::loadFromSaveFile(const char *filename) {
|
||||
assert(g_system);
|
||||
SaveFileManager *saveFileMan = g_system->getSavefileManager();
|
||||
SeekableReadStream *loadFile;
|
||||
|
||||
assert(saveFileMan);
|
||||
if (!(loadFile = saveFileMan->openForLoading(filename)))
|
||||
return false;
|
||||
|
||||
|
@ -189,9 +191,11 @@ bool ConfigFile::saveToFile(const String &filename) {
|
|||
}
|
||||
|
||||
bool ConfigFile::saveToSaveFile(const char *filename) {
|
||||
assert(g_system);
|
||||
SaveFileManager *saveFileMan = g_system->getSavefileManager();
|
||||
WriteStream *saveFile;
|
||||
|
||||
assert(saveFileMan);
|
||||
if (!(saveFile = saveFileMan->openForSaving(filename)))
|
||||
return false;
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ ConfigManager::ConfigManager()
|
|||
|
||||
void ConfigManager::loadDefaultConfigFile() {
|
||||
// Open the default config file
|
||||
assert(g_system);
|
||||
SeekableReadStream *stream = g_system->createConfigReadStream();
|
||||
_filename.clear(); // clear the filename to indicate that we are using the default config file
|
||||
|
||||
|
@ -190,6 +191,7 @@ void ConfigManager::flushToDisk() {
|
|||
|
||||
if (_filename.empty()) {
|
||||
// Write to the default config file
|
||||
assert(g_system);
|
||||
stream = g_system->createConfigWriteStream();
|
||||
if (!stream) // If writing to the config file is not possible, do nothing
|
||||
return;
|
||||
|
|
|
@ -37,6 +37,7 @@ FSNode::FSNode(AbstractFSNode *realNode)
|
|||
}
|
||||
|
||||
FSNode::FSNode(const Common::String &p) {
|
||||
assert(g_system);
|
||||
FilesystemFactory *factory = g_system->getFilesystemFactory();
|
||||
AbstractFSNode *tmp = 0;
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
namespace Common {
|
||||
|
||||
Mutex::Mutex() {
|
||||
assert(g_system);
|
||||
_mutex = g_system->createMutex();
|
||||
}
|
||||
|
||||
|
|
|
@ -472,17 +472,16 @@ static void debugHelper(const char *in_buf, bool caret = true) {
|
|||
g_engine->errorString(in_buf, buf, STRINGBUFLEN);
|
||||
} else {
|
||||
strncpy(buf, in_buf, STRINGBUFLEN);
|
||||
buf[STRINGBUFLEN-1] = '\0';
|
||||
}
|
||||
buf[STRINGBUFLEN-2] = '\0';
|
||||
buf[STRINGBUFLEN-1] = '\0';
|
||||
|
||||
if (caret)
|
||||
printf("%s\n", buf);
|
||||
else
|
||||
printf("%s", buf);
|
||||
|
||||
#if defined( USE_WINDBG )
|
||||
if (caret)
|
||||
strcat(buf, "\n");
|
||||
|
||||
fprintf(stdout, "%s", buf); // FIXME: Use fputs instead
|
||||
|
||||
#if defined( USE_WINDBG )
|
||||
#if defined( _WIN32_WCE )
|
||||
TCHAR buf_unicode[1024];
|
||||
MultiByteToWideChar(CP_ACP, 0, buf, strlen(buf) + 1, buf_unicode, sizeof(buf_unicode));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue