[*] Console exit must be called last in case any unexpected error occurs during deinitialization

[*] Fix up wxwidgets
This commit is contained in:
Reece Wilson 2021-07-01 11:42:48 +01:00
parent b9da9c313e
commit 5676ef84fb
3 changed files with 38 additions and 7 deletions

View File

@ -87,7 +87,9 @@ private:
void OnAbout(wxCommandEvent &event); void OnAbout(wxCommandEvent &event);
void OnBugWrite(wxCommandEvent &event); void OnBugWrite(wxCommandEvent &event);
void OnInit(wxWindowCreateEvent &event); void OnInit(wxWindowCreateEvent &event);
void OnShow(wxWindowCreateEvent &event);
void OnCmd(wxCommandEvent &event); void OnCmd(wxCommandEvent &event);
void OnPump(wxTimerEvent& event);
WxSplitterLine *NewSplitter(wxSize splitter, wxColor color); WxSplitterLine *NewSplitter(wxSize splitter, wxColor color);
@ -97,6 +99,7 @@ private:
wxMenuBar *menuBar_; wxMenuBar *menuBar_;
wxBoxSizer *sizer_; wxBoxSizer *sizer_;
AuList<WxSplitterLine *> _splitters; AuList<WxSplitterLine *> _splitters;
wxTimer timer_;
}; };
enum enum
@ -289,11 +292,12 @@ ConsoleFrame::ConsoleFrame(const wxString &title, const wxPoint &pos, const wxSi
commandbox_->SetBackgroundColour(wxColour(0, 0, 0)); commandbox_->SetBackgroundColour(wxColour(0, 0, 0));
commandbox_->SetForegroundColour(wxColour(255, 255, 255)); commandbox_->SetForegroundColour(wxColour(255, 255, 255));
this->Connect(wxEVT_SHOW, wxWindowCreateEventHandler(ConsoleFrame::OnInit)); //this->Connect(wxEVT_SHOW, wxWindowCreateEventHandler(ConsoleFrame::OnShow));
} }
commandbox_->SetHint("Type a command here"); commandbox_->SetHint("Type a command here");
commandbox_->Connect(wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(ConsoleFrame::OnCmd)); commandbox_->Connect(wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(ConsoleFrame::OnCmd));
//commandbox_->Bind(wxEVT_COMMAND_TEXT_ENTER, &ConsoleFrame::OnCmd, commandbox_);
sizer_ = _new wxBoxSizer(wxVERTICAL); sizer_ = _new wxBoxSizer(wxVERTICAL);
if (!sizer_) return; if (!sizer_) return;
@ -314,6 +318,8 @@ ConsoleFrame::ConsoleFrame(const wxString &title, const wxPoint &pos, const wxSi
SetSizer(sizer_); SetSizer(sizer_);
SetMenuBar(menuBar_); SetMenuBar(menuBar_);
timer_.Bind(wxEVT_TIMER, &ConsoleFrame::OnPump, this);
timer_.Start(100);
gWxConsoleReady = true; gWxConsoleReady = true;
} }
@ -327,6 +333,11 @@ static bool DarkModeEnabled()
} }
void ConsoleFrame::OnInit(wxWindowCreateEvent &event) void ConsoleFrame::OnInit(wxWindowCreateEvent &event)
{
OnShow(event);
}
void ConsoleFrame::OnShow(wxWindowCreateEvent &event)
{ {
if (!DarkModeEnabled()) return; if (!DarkModeEnabled()) return;
@ -344,6 +355,12 @@ void ConsoleFrame::OnInit(wxWindowCreateEvent &event)
} }
#else #else
void ConsoleFrame::OnInit(wxWindowCreateEvent &event)
{}
void ConsoleFrame::OnShow(wxWindowCreateEvent &event)
{}
static bool DarkModeEnabled() static bool DarkModeEnabled()
{ {
return Aurora::Build::EPlatform == Aurora::Build::EPlatform::kPlatformLinux; return Aurora::Build::EPlatform == Aurora::Build::EPlatform::kPlatformLinux;
@ -370,6 +387,15 @@ void ConsoleFrame::OnBugWrite(wxCommandEvent &event)
Aurora::Processes::OpenUri(gRuntimeConfig.console.supportInternal); Aurora::Processes::OpenUri(gRuntimeConfig.console.supportInternal);
} }
namespace Aurora::Console::ConsoleWxWidgets
{
static void WxWidgetsPump();
}
void ConsoleFrame::OnPump(wxTimerEvent &event)
{
Aurora::Console::ConsoleWxWidgets::WxWidgetsPump();
}
namespace Aurora::Console::ConsoleWxWidgets namespace Aurora::Console::ConsoleWxWidgets
{ {
@ -397,10 +423,6 @@ namespace Aurora::Console::ConsoleWxWidgets
static bool WxWidgetsInit() static bool WxWidgetsInit()
{ {
#if defined(AURORA_PLATFORM_WIN32)
Aurora::Extensions::Win32::InitDarkMode();
#endif
wxApp::SetInstance(_new ConsoleApp()); wxApp::SetInstance(_new ConsoleApp());
#if defined(AURORA_PLATFORM_WIN32) || true #if defined(AURORA_PLATFORM_WIN32) || true
@ -536,6 +558,7 @@ namespace Aurora::Console::ConsoleWxWidgets
void Pump() void Pump()
{ {
#if 0
Aurora::Threading::LockGuardPtr re(gMutex.get()); Aurora::Threading::LockGuardPtr re(gMutex.get());
if (!gWxConsoleReady) return; if (!gWxConsoleReady) return;
@ -544,6 +567,7 @@ namespace Aurora::Console::ConsoleWxWidgets
{ {
WxWidgetsPump(); WxWidgetsPump();
}); });
#endif
} }
void Exit() void Exit()

View File

@ -17,9 +17,16 @@
#include "Hashing/Hashing.hpp" #include "Hashing/Hashing.hpp"
#include "Debug/Debug.hpp" #include "Debug/Debug.hpp"
#include "Async/Async.hpp" #include "Async/Async.hpp"
#if defined(AURORA_PLATFORM_WIN32)
#include "Extensions/Win32/DarkTheme.hpp"
#endif
static void Init() static void Init()
{ {
#if defined(AURORA_PLATFORM_WIN32)
Aurora::Extensions::Win32::InitDarkMode();
#endif
Crypto::InitCrypto(); Crypto::InitCrypto();
Aurora::Console::Init(); Aurora::Console::Init();
Aurora::IO::FS::InitResources(); Aurora::IO::FS::InitResources();
@ -40,8 +47,8 @@ static void Pump()
static void Deinit() static void Deinit()
{ {
Aurora::RNG::Release(); Aurora::RNG::Release();
Aurora::Console::Exit();
Aurora::Async::ShutdownAsync(); Aurora::Async::ShutdownAsync();
Aurora::Console::Exit();
} }
namespace Aurora namespace Aurora

View File

@ -125,7 +125,7 @@ namespace Aurora::Extensions::Win32
DWORD major, minor; DWORD major, minor;
RtlGetNtVersionNumbers(&major, &minor, &g_buildNumber); RtlGetNtVersionNumbers(&major, &minor, &g_buildNumber);
g_buildNumber &= ~0xF0000000; g_buildNumber &= ~0xF0000000;
if (major != 10 || minor != 0 || !CheckBuildNumber(g_buildNumber)) if (major != 10 || minor != 0)// || !CheckBuildNumber(g_buildNumber))
{ {
return; return;
} }