mirror of
https://github.com/glest/glest-source.git
synced 2025-02-24 03:32:35 +01:00
Some bugfixing for logfile saving after testing in win32
This commit is contained in:
parent
ae10ab55b2
commit
1fbff088e4
@ -31,6 +31,8 @@ using namespace Shared::Util;
|
||||
|
||||
namespace Glest{ namespace Game{
|
||||
|
||||
string debugLogFile = "";
|
||||
|
||||
// =====================================================
|
||||
// class ExceptionHandler
|
||||
// =====================================================
|
||||
@ -39,9 +41,12 @@ class ExceptionHandler: public PlatformExceptionHandler{
|
||||
public:
|
||||
virtual void handle(){
|
||||
|
||||
string msg = "An error ocurred and Glest will close.\nPlease report this bug to "+mailString+", attaching the generated "+getCrashDumpFileName()+" file.";
|
||||
string msg = "#1 An error ocurred and Glest will close.\nPlease report this bug to "+mailString+", attaching the generated "+getCrashDumpFileName()+" file.";
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n",msg.c_str());
|
||||
|
||||
Program *program = Program::getInstance();
|
||||
if(program) {
|
||||
//SystemFlags::Close();
|
||||
program->showMessage(msg.c_str());
|
||||
}
|
||||
|
||||
@ -49,15 +54,20 @@ public:
|
||||
}
|
||||
|
||||
static void handleRuntimeError(const char *msg) {
|
||||
Program *program = Program::getInstance();
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n",msg);
|
||||
|
||||
Program *program = Program::getInstance();
|
||||
if(program) {
|
||||
//SystemFlags::Close();
|
||||
program->showMessage(msg);
|
||||
}
|
||||
else {
|
||||
message("An error ocurred and Glest will close.\nError msg = [" + (msg != NULL ? string(msg) : string("?")) + "]\n\nPlease report this bug to "+mailString+", attaching the generated "+getCrashDumpFileName()+" file.");
|
||||
message("#2 An error ocurred and Glest will close.\nError msg = [" + (msg != NULL ? string(msg) : string("?")) + "]\n\nPlease report this bug to "+mailString+", attaching the generated "+getCrashDumpFileName()+" file.");
|
||||
}
|
||||
|
||||
restoreVideoMode(true);
|
||||
//SystemFlags::Close();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@ -73,6 +83,8 @@ public:
|
||||
|
||||
if(exitApp == true) {
|
||||
restoreVideoMode(true);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n",msg);
|
||||
//SystemFlags::Close();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@ -167,7 +179,6 @@ int glestMain(int argc, char** argv){
|
||||
Program *program= NULL;
|
||||
ExceptionHandler exceptionHandler;
|
||||
exceptionHandler.install( getCrashDumpFileName() );
|
||||
string debugLogFile = "";
|
||||
|
||||
try{
|
||||
Config &config = Config::getInstance();
|
||||
@ -216,6 +227,7 @@ int glestMain(int argc, char** argv){
|
||||
}
|
||||
|
||||
delete mainWindow;
|
||||
//SystemFlags::Close();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||
//textures 3d
|
||||
listBoxTextures3D.pushBackItem(lang.get("No"));
|
||||
listBoxTextures3D.pushBackItem(lang.get("Yes"));
|
||||
listBoxTextures3D.setSelectedItemIndex(clamp(config.getInt("Textures3D"), 0, 1));
|
||||
listBoxTextures3D.setSelectedItemIndex(clamp(config.getBool("Textures3D"), false, true));
|
||||
|
||||
//textures 3d
|
||||
listBoxUnitParticles.pushBackItem(lang.get("No"));
|
||||
@ -268,7 +268,7 @@ void MenuStateOptions::saveConfig(){
|
||||
config.setString("Shadows", Renderer::shadowsToStr(static_cast<Renderer::Shadows>(index)));
|
||||
|
||||
config.setString("Filter", listBoxFilter.getSelectedItem());
|
||||
config.setInt("Textures3D", listBoxTextures3D.getSelectedItemIndex());
|
||||
config.setBool("Textures3D", listBoxTextures3D.getSelectedItemIndex());
|
||||
config.setBool("UnitParticles", listBoxUnitParticles.getSelectedItemIndex());
|
||||
config.setInt("MaxLights", listBoxLights.getSelectedItemIndex()+1);
|
||||
config.setString("SoundVolumeFx", listBoxVolumeFx.getSelectedItem());
|
||||
|
@ -13,6 +13,7 @@
|
||||
#define _SHARED_UTIL_UTIL_H_
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
|
||||
using std::string;
|
||||
|
||||
@ -20,6 +21,9 @@ namespace Shared{ namespace Util{
|
||||
|
||||
class SystemFlags
|
||||
{
|
||||
protected:
|
||||
|
||||
static std::ofstream fileStream;
|
||||
public:
|
||||
|
||||
enum DebugType {
|
||||
@ -32,6 +36,7 @@ public:
|
||||
static const char *debugLogFile;
|
||||
|
||||
static void OutputDebug(DebugType type, const char *fmt, ...);
|
||||
static void Close();
|
||||
};
|
||||
|
||||
const string sharedLibVersionString= "v0.4.1";
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <stdarg.h>
|
||||
#include <fstream>
|
||||
|
||||
#include "leak_dumper.h"
|
||||
|
||||
@ -25,10 +24,16 @@ using namespace std;
|
||||
|
||||
namespace Shared{ namespace Util{
|
||||
|
||||
|
||||
bool SystemFlags::enableDebugText = false;
|
||||
bool SystemFlags::enableNetworkDebugInfo = false;
|
||||
const char * SystemFlags::debugLogFile = NULL;
|
||||
ofstream SystemFlags::fileStream;
|
||||
|
||||
void SystemFlags::Close() {
|
||||
if(fileStream.is_open() == true) {
|
||||
SystemFlags::fileStream.close();
|
||||
}
|
||||
}
|
||||
|
||||
void SystemFlags::OutputDebug(DebugType type, const char *fmt, ...) {
|
||||
if((type == debugSystem && SystemFlags::enableDebugText == false) ||
|
||||
@ -41,7 +46,6 @@ void SystemFlags::OutputDebug(DebugType type, const char *fmt, ...) {
|
||||
|
||||
// Either output to a logfile or
|
||||
if(SystemFlags::debugLogFile != NULL && SystemFlags::debugLogFile[0] != 0) {
|
||||
static ofstream fileStream;
|
||||
if(fileStream.is_open() == false) {
|
||||
printf("Opening logfile [%s]\n",SystemFlags::debugLogFile);
|
||||
fileStream.open(SystemFlags::debugLogFile, ios_base::out | ios_base::trunc);
|
||||
|
Loading…
x
Reference in New Issue
Block a user