mirror of
https://github.com/edubart/otclient.git
synced 2025-10-17 13:03:27 +02:00
display MessageBox in win32 on fatal errors
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "logger.h"
|
||||
#include "eventdispatcher.h"
|
||||
#include <framework/platform/platform.h>
|
||||
|
||||
Logger g_logger;
|
||||
|
||||
@@ -47,6 +48,7 @@ void Logger::log(Fw::LogLevel level, std::string message)
|
||||
|
||||
if(level == Fw::LogFatal) {
|
||||
m_terminated = true;
|
||||
g_platform.displayFatalError(message);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
@@ -42,7 +42,7 @@ void ModuleManager::discoverAndLoadModules()
|
||||
for(const ModulePtr& module : m_modules) {
|
||||
if(!module->isLoaded() && module->autoLoad()) {
|
||||
if(!module->load())
|
||||
logFatal("cannot continue to run");
|
||||
logFatal("A required module has failed to load, cannot continue to run.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -52,7 +52,7 @@ void ResourceManager::init(const char* argv0, const char *appName)
|
||||
}
|
||||
|
||||
if(!found)
|
||||
logFatal("could not find modules directory");
|
||||
logFatal("Could not find modules directory.");
|
||||
|
||||
// setup write directory
|
||||
std::string dir = g_platform.getAppUserDir();
|
||||
|
@@ -82,6 +82,8 @@ public:
|
||||
/// Get the app user directory, the place to save files configurations files
|
||||
std::string getAppUserDir();
|
||||
|
||||
void displayFatalError(const std::string& message);
|
||||
|
||||
private:
|
||||
int m_lastTicks;
|
||||
};
|
||||
|
@@ -289,7 +289,7 @@ void Platform::init(PlatformListener* platformListener, const char *appName)
|
||||
wc.lpszClassName = win32.appName.c_str(); // Set The Class Name
|
||||
|
||||
if(!RegisterClassA(&wc))
|
||||
logFatal("FATAL ERROR: Failed to register the window class.");
|
||||
logFatal("Failed to register the window class.");
|
||||
|
||||
// force first tick
|
||||
updateTicks();
|
||||
@@ -737,3 +737,9 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Platform::displayFatalError(const std::string& message)
|
||||
{
|
||||
MessageBoxA(NULL, message.c_str(), "Fatal Error", MB_OK | MB_ICONERROR);
|
||||
}
|
||||
|
||||
|
@@ -962,3 +962,8 @@ std::string Platform::getAppUserDir()
|
||||
logError("Couldn't create directory for saving configuration file. (",sdir.str(),")");
|
||||
return sdir.str();
|
||||
}
|
||||
|
||||
void Platform::displayFatalError(const std::string& message)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
Reference in New Issue
Block a user