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{
|
namespace Glest{ namespace Game{
|
||||||
|
|
||||||
|
string debugLogFile = "";
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class ExceptionHandler
|
// class ExceptionHandler
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
@ -39,9 +41,12 @@ class ExceptionHandler: public PlatformExceptionHandler{
|
||||||
public:
|
public:
|
||||||
virtual void handle(){
|
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();
|
Program *program = Program::getInstance();
|
||||||
if(program) {
|
if(program) {
|
||||||
|
//SystemFlags::Close();
|
||||||
program->showMessage(msg.c_str());
|
program->showMessage(msg.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,15 +54,20 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handleRuntimeError(const char *msg) {
|
static void handleRuntimeError(const char *msg) {
|
||||||
Program *program = Program::getInstance();
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n",msg);
|
||||||
|
|
||||||
|
Program *program = Program::getInstance();
|
||||||
if(program) {
|
if(program) {
|
||||||
|
//SystemFlags::Close();
|
||||||
program->showMessage(msg);
|
program->showMessage(msg);
|
||||||
}
|
}
|
||||||
else {
|
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);
|
restoreVideoMode(true);
|
||||||
|
//SystemFlags::Close();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,6 +83,8 @@ public:
|
||||||
|
|
||||||
if(exitApp == true) {
|
if(exitApp == true) {
|
||||||
restoreVideoMode(true);
|
restoreVideoMode(true);
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n",msg);
|
||||||
|
//SystemFlags::Close();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +179,6 @@ int glestMain(int argc, char** argv){
|
||||||
Program *program= NULL;
|
Program *program= NULL;
|
||||||
ExceptionHandler exceptionHandler;
|
ExceptionHandler exceptionHandler;
|
||||||
exceptionHandler.install( getCrashDumpFileName() );
|
exceptionHandler.install( getCrashDumpFileName() );
|
||||||
string debugLogFile = "";
|
|
||||||
|
|
||||||
try{
|
try{
|
||||||
Config &config = Config::getInstance();
|
Config &config = Config::getInstance();
|
||||||
|
@ -216,6 +227,7 @@ int glestMain(int argc, char** argv){
|
||||||
}
|
}
|
||||||
|
|
||||||
delete mainWindow;
|
delete mainWindow;
|
||||||
|
//SystemFlags::Close();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||||
//textures 3d
|
//textures 3d
|
||||||
listBoxTextures3D.pushBackItem(lang.get("No"));
|
listBoxTextures3D.pushBackItem(lang.get("No"));
|
||||||
listBoxTextures3D.pushBackItem(lang.get("Yes"));
|
listBoxTextures3D.pushBackItem(lang.get("Yes"));
|
||||||
listBoxTextures3D.setSelectedItemIndex(clamp(config.getInt("Textures3D"), 0, 1));
|
listBoxTextures3D.setSelectedItemIndex(clamp(config.getBool("Textures3D"), false, true));
|
||||||
|
|
||||||
//textures 3d
|
//textures 3d
|
||||||
listBoxUnitParticles.pushBackItem(lang.get("No"));
|
listBoxUnitParticles.pushBackItem(lang.get("No"));
|
||||||
|
@ -268,7 +268,7 @@ void MenuStateOptions::saveConfig(){
|
||||||
config.setString("Shadows", Renderer::shadowsToStr(static_cast<Renderer::Shadows>(index)));
|
config.setString("Shadows", Renderer::shadowsToStr(static_cast<Renderer::Shadows>(index)));
|
||||||
|
|
||||||
config.setString("Filter", listBoxFilter.getSelectedItem());
|
config.setString("Filter", listBoxFilter.getSelectedItem());
|
||||||
config.setInt("Textures3D", listBoxTextures3D.getSelectedItemIndex());
|
config.setBool("Textures3D", listBoxTextures3D.getSelectedItemIndex());
|
||||||
config.setBool("UnitParticles", listBoxUnitParticles.getSelectedItemIndex());
|
config.setBool("UnitParticles", listBoxUnitParticles.getSelectedItemIndex());
|
||||||
config.setInt("MaxLights", listBoxLights.getSelectedItemIndex()+1);
|
config.setInt("MaxLights", listBoxLights.getSelectedItemIndex()+1);
|
||||||
config.setString("SoundVolumeFx", listBoxVolumeFx.getSelectedItem());
|
config.setString("SoundVolumeFx", listBoxVolumeFx.getSelectedItem());
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#define _SHARED_UTIL_UTIL_H_
|
#define _SHARED_UTIL_UTIL_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
|
@ -20,6 +21,9 @@ namespace Shared{ namespace Util{
|
||||||
|
|
||||||
class SystemFlags
|
class SystemFlags
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
|
||||||
|
static std::ofstream fileStream;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum DebugType {
|
enum DebugType {
|
||||||
|
@ -32,6 +36,7 @@ public:
|
||||||
static const char *debugLogFile;
|
static const char *debugLogFile;
|
||||||
|
|
||||||
static void OutputDebug(DebugType type, const char *fmt, ...);
|
static void OutputDebug(DebugType type, const char *fmt, ...);
|
||||||
|
static void Close();
|
||||||
};
|
};
|
||||||
|
|
||||||
const string sharedLibVersionString= "v0.4.1";
|
const string sharedLibVersionString= "v0.4.1";
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
|
@ -25,10 +24,16 @@ using namespace std;
|
||||||
|
|
||||||
namespace Shared{ namespace Util{
|
namespace Shared{ namespace Util{
|
||||||
|
|
||||||
|
|
||||||
bool SystemFlags::enableDebugText = false;
|
bool SystemFlags::enableDebugText = false;
|
||||||
bool SystemFlags::enableNetworkDebugInfo = false;
|
bool SystemFlags::enableNetworkDebugInfo = false;
|
||||||
const char * SystemFlags::debugLogFile = NULL;
|
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, ...) {
|
void SystemFlags::OutputDebug(DebugType type, const char *fmt, ...) {
|
||||||
if((type == debugSystem && SystemFlags::enableDebugText == false) ||
|
if((type == debugSystem && SystemFlags::enableDebugText == false) ||
|
||||||
|
@ -41,7 +46,6 @@ void SystemFlags::OutputDebug(DebugType type, const char *fmt, ...) {
|
||||||
|
|
||||||
// Either output to a logfile or
|
// Either output to a logfile or
|
||||||
if(SystemFlags::debugLogFile != NULL && SystemFlags::debugLogFile[0] != 0) {
|
if(SystemFlags::debugLogFile != NULL && SystemFlags::debugLogFile[0] != 0) {
|
||||||
static ofstream fileStream;
|
|
||||||
if(fileStream.is_open() == false) {
|
if(fileStream.is_open() == false) {
|
||||||
printf("Opening logfile [%s]\n",SystemFlags::debugLogFile);
|
printf("Opening logfile [%s]\n",SystemFlags::debugLogFile);
|
||||||
fileStream.open(SystemFlags::debugLogFile, ios_base::out | ios_base::trunc);
|
fileStream.open(SystemFlags::debugLogFile, ios_base::out | ios_base::trunc);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user