Console: make ConsoleWindow immune to constructor ordering

This commit is contained in:
Wolfgang Thaller 2017-09-24 19:59:54 +02:00
parent 284126e13c
commit a5dad80454

View File

@ -25,7 +25,7 @@ using namespace Retro;
namespace namespace
{ {
std::unordered_map<WindowPtr, ConsoleWindow*> windows; std::unordered_map<WindowPtr, ConsoleWindow*> *windows = NULL;
} }
ConsoleWindow::ConsoleWindow(Rect r, ConstStr255Param title) ConsoleWindow::ConsoleWindow(Rect r, ConstStr255Param title)
@ -46,14 +46,16 @@ ConsoleWindow::ConsoleWindow(Rect r, ConstStr255Param title)
SetPort(port); SetPort(port);
EraseRect(&portRect); EraseRect(&portRect);
windows[win] = this; if(!windows)
windows = new std::unordered_map<WindowPtr, ConsoleWindow*>();
(*windows)[win] = this;
Init(port, portRect); Init(port, portRect);
} }
ConsoleWindow::~ConsoleWindow() ConsoleWindow::~ConsoleWindow()
{ {
windows.erase(win); windows->erase(win);
DisposeWindow(win); DisposeWindow(win);
} }
@ -85,7 +87,7 @@ char ConsoleWindow::WaitNextChar()
{ {
case updateEvt: case updateEvt:
eventWin = (WindowPtr)event.message; eventWin = (WindowPtr)event.message;
realConsole = windows[(WindowPtr)event.message]; realConsole = (*windows)[(WindowPtr)event.message];
if(realConsole) if(realConsole)
{ {
Rect updateRect; Rect updateRect;