[Scummvm-cvs-logs] SF.net SVN: scummvm:[36131] scummvm/trunk/common

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Thu Jan 29 23:09:06 CET 2009


Revision: 36131
          http://scummvm.svn.sourceforge.net/scummvm/?rev=36131&view=rev
Author:   fingolfin
Date:     2009-01-29 22:09:06 +0000 (Thu, 29 Jan 2009)

Log Message:
-----------
Be paranoid about g_system being set

Modified Paths:
--------------
    scummvm/trunk/common/archive.cpp
    scummvm/trunk/common/config-file.cpp
    scummvm/trunk/common/config-manager.cpp
    scummvm/trunk/common/fs.cpp
    scummvm/trunk/common/mutex.cpp
    scummvm/trunk/common/util.cpp

Modified: scummvm/trunk/common/archive.cpp
===================================================================
--- scummvm/trunk/common/archive.cpp	2009-01-29 21:34:59 UTC (rev 36130)
+++ scummvm/trunk/common/archive.cpp	2009-01-29 22:09:06 UTC (rev 36131)
@@ -460,7 +460,8 @@
 	// 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.
-	g_system->addSysArchivesToSearchSet(*this, -1);
+	if (g_system)
+		g_system->addSysArchivesToSearchSet(*this, -1);
 
 	// Add the current dir as a very last resort.
 	// See also bug #2137680.

Modified: scummvm/trunk/common/config-file.cpp
===================================================================
--- scummvm/trunk/common/config-file.cpp	2009-01-29 21:34:59 UTC (rev 36130)
+++ scummvm/trunk/common/config-file.cpp	2009-01-29 22:09:06 UTC (rev 36131)
@@ -65,9 +65,11 @@
 }
 
 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::saveToSaveFile(const char *filename) {
+	assert(g_system);
 	SaveFileManager *saveFileMan = g_system->getSavefileManager();
 	WriteStream *saveFile;
 
+	assert(saveFileMan);
 	if (!(saveFile = saveFileMan->openForSaving(filename)))
 		return false;
 

Modified: scummvm/trunk/common/config-manager.cpp
===================================================================
--- scummvm/trunk/common/config-manager.cpp	2009-01-29 21:34:59 UTC (rev 36130)
+++ scummvm/trunk/common/config-manager.cpp	2009-01-29 22:09:06 UTC (rev 36131)
@@ -62,6 +62,7 @@
 
 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 @@
 
 	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;

Modified: scummvm/trunk/common/fs.cpp
===================================================================
--- scummvm/trunk/common/fs.cpp	2009-01-29 21:34:59 UTC (rev 36130)
+++ scummvm/trunk/common/fs.cpp	2009-01-29 22:09:06 UTC (rev 36131)
@@ -37,6 +37,7 @@
 }
 
 FSNode::FSNode(const Common::String &p) {
+	assert(g_system);
 	FilesystemFactory *factory = g_system->getFilesystemFactory();
 	AbstractFSNode *tmp = 0;
 

Modified: scummvm/trunk/common/mutex.cpp
===================================================================
--- scummvm/trunk/common/mutex.cpp	2009-01-29 21:34:59 UTC (rev 36130)
+++ scummvm/trunk/common/mutex.cpp	2009-01-29 22:09:06 UTC (rev 36131)
@@ -29,6 +29,7 @@
 namespace Common {
 
 Mutex::Mutex() {
+	assert(g_system);
 	_mutex = g_system->createMutex();
 }
 

Modified: scummvm/trunk/common/util.cpp
===================================================================
--- scummvm/trunk/common/util.cpp	2009-01-29 21:34:59 UTC (rev 36130)
+++ scummvm/trunk/common/util.cpp	2009-01-29 22:09:06 UTC (rev 36131)
@@ -472,17 +472,16 @@
 		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);
+		strcat(buf, "\n");
 
+	fprintf(stdout, "%s", buf);	// FIXME: Use fputs instead
+
 #if defined( USE_WINDBG )
-	if (caret)
-		strcat(buf, "\n");
 #if defined( _WIN32_WCE )
 	TCHAR buf_unicode[1024];
 	MultiByteToWideChar(CP_ACP, 0, buf, strlen(buf) + 1, buf_unicode, sizeof(buf_unicode));


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list