Skip to content

Commit

Permalink
Fixed|Client: Crash during main window construction
Browse files Browse the repository at this point in the history
It was possible that the log was flushed during construction of the
main window, which lead to the log alerter attempting to access a
partially constructed object.

Now ClientWindow::mainExists() only returns true if the main window
has been fully constructed.
  • Loading branch information
skyjake committed Nov 7, 2014
1 parent c05210a commit 607a18c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions doomsday/client/include/ui/clientwindow.h
Expand Up @@ -170,6 +170,7 @@ class ClientWindow : public de::BaseWindow,
bool handleFallbackEvent(de::Event const &event);

static ClientWindow &main();
static bool mainExists();

protected:
bool prepareForDraw();
Expand Down
18 changes: 18 additions & 0 deletions doomsday/client/src/ui/clientwindow.cpp
Expand Up @@ -66,6 +66,8 @@ static inline InputSystem &inputSys()
return ClientApp::inputSystem();
}

static ClientWindow *mainWindow = nullptr; // The main window, set after fully constructed.

DENG2_PIMPL(ClientWindow)
, DENG2_OBSERVES(MouseEventSource, MouseStateChange)
, DENG2_OBSERVES(Canvas, FocusChange)
Expand Down Expand Up @@ -151,6 +153,11 @@ DENG2_PIMPL(ClientWindow)

releaseRef(cursorX);
releaseRef(cursorY);

if(thisPublic == mainWindow)
{
mainWindow = nullptr;
}
}

Widget &container()
Expand Down Expand Up @@ -736,6 +743,12 @@ ClientWindow::ClientWindow(String const &id)
#endif

d->setupUI();

// The first window is the main window.
if(!mainWindow)
{
mainWindow = this;
}
}

Vector2f ClientWindow::windowContentSize() const
Expand Down Expand Up @@ -1036,6 +1049,11 @@ ClientWindow &ClientWindow::main()
return static_cast<ClientWindow &>(BaseWindow::main());
}

bool ClientWindow::mainExists()
{
return mainWindow != nullptr;
}

void ClientWindow::toggleFPSCounter()
{
App::config().set(configName("showFps"), !isFPSCounterVisible());
Expand Down
5 changes: 5 additions & 0 deletions doomsday/config_win32.pri
Expand Up @@ -36,6 +36,11 @@ deng_msvc {
QMAKE_RC = $$QMAKE_RC /I \"$$DENG_API_DIR\"

deng_debug: QMAKE_RC = $$QMAKE_RC /d _DEBUG

!deng_debug:deng_debuginfo {
QMAKE_CFLAGS += -Z7 -DEBUG
QMAKE_CXXFLAGS += -Z7 -DEBUG
}
}
deng_mingw {
QMAKE_RC = $$QMAKE_RC --include-dir=\"$$DENG_API_DIR\"
Expand Down

0 comments on commit 607a18c

Please sign in to comment.