Logging fixed

Now it displays messagebox if logging system isn't initialized.
Otherwise it could cause stack overflow.
This commit is contained in:
Nekotekina 2015-04-25 16:29:05 +03:00
parent 5d6d058965
commit c5737d01c6
4 changed files with 26 additions and 14 deletions

View File

@ -9,7 +9,7 @@
using namespace Log;
LogManager *gLogManager = nullptr;
std::unique_ptr<LogManager> g_log_manager;
u32 LogMessage::size() const
{
@ -224,6 +224,7 @@ void LogManager::addListener(std::shared_ptr<LogListener> listener)
channel.addListener(listener);
}
}
void LogManager::removeListener(std::shared_ptr<LogListener> listener)
{
for (auto& channel : mChannels)
@ -234,12 +235,14 @@ void LogManager::removeListener(std::shared_ptr<LogListener> listener)
LogManager& LogManager::getInstance()
{
if (!gLogManager)
if (!g_log_manager)
{
gLogManager = new LogManager();
g_log_manager.reset(new LogManager());
}
return *gLogManager;
return *g_log_manager;
}
LogChannel &LogManager::getChannel(LogType type)
{
return mChannels[static_cast<u32>(type)];
@ -252,9 +255,22 @@ void log_message(Log::LogType type, Log::LogSeverity sev, const char* text)
void log_message(Log::LogType type, Log::LogSeverity sev, std::string text)
{
//another msvc bug makes this not work, uncomment this and delete everything else in this function when it's fixed
//Log::LogManager::getInstance().log({logType, severity, text})
Log::LogMessage msg{ type, sev, std::move(text) };
Log::LogManager::getInstance().log(msg);
if (g_log_manager)
{
// another msvc bug makes this not work, uncomment this when it's fixed
//g_log_manager->log({logType, severity, text});
Log::LogMessage msg{ type, sev, std::move(text) };
g_log_manager->log(msg);
}
else
{
rMessageBox(text,
sev == Notice ? "Notice" :
sev == Warning ? "Warning" :
sev == Success ? "Success" :
sev == Error ? "Error" : "Unknown",
sev == Notice ? rICON_INFORMATION :
sev == Warning ? rICON_EXCLAMATION :
sev == Error ? rICON_ERROR : rICON_INFORMATION);
}
}

View File

@ -1,7 +1,5 @@
#pragma once
static std::thread::id main_thread;
class NamedThreadBase
{
std::string m_name;

View File

@ -122,9 +122,9 @@ MainFrame::MainFrame()
SetMenuBar(menubar);
// Panels
m_log_frame = new LogFrame(this);
m_game_viewer = new GameViewer(this);
m_debugger_frame = new DebuggerPanel(this);
m_log_frame = new LogFrame(this);
AddPane(m_game_viewer, "Game List", wxAUI_DOCK_CENTRE);
AddPane(m_log_frame, "Log", wxAUI_DOCK_BOTTOM);

View File

@ -148,8 +148,6 @@ bool Rpcs3App::OnInit()
const wxString executablePath = wxPathOnly(wxStandardPaths::Get().GetExecutablePath());
wxSetWorkingDirectory(executablePath);
main_thread = std::this_thread::get_id();
Ini.Load();
Emu.Init();
Emu.SetEmulatorPath(executablePath.ToStdString());