Skip to content

Commit

Permalink
Fixed|Client: Null pointer access if shutting down too early
Browse files Browse the repository at this point in the history
The input system may be missing when an error occurs.
  • Loading branch information
skyjake committed Jul 7, 2015
1 parent d1d97dc commit 68823ad
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions doomsday/apps/client/include/clientapp.h
Expand Up @@ -76,6 +76,7 @@ class ClientApp : public de::BaseGuiApp
static de::Games &games();
static de::WorldSystem &worldSystem();

static bool hasInputSystem();
static bool hasRenderSystem();

public slots:
Expand Down
7 changes: 6 additions & 1 deletion doomsday/apps/client/src/clientapp.cpp
Expand Up @@ -504,6 +504,11 @@ InputSystem &ClientApp::inputSystem()
return *a.d->inputSys;
}

bool ClientApp::hasInputSystem()
{
return ClientApp::app().d->inputSys != nullptr;
}

RenderSystem &ClientApp::renderSystem()
{
ClientApp &a = ClientApp::app();
Expand All @@ -513,7 +518,7 @@ RenderSystem &ClientApp::renderSystem()

bool ClientApp::hasRenderSystem()
{
return ClientApp::app().d->rendSys != 0;
return ClientApp::app().d->rendSys != nullptr;
}

ResourceSystem &ClientApp::resourceSystem()
Expand Down
6 changes: 5 additions & 1 deletion doomsday/apps/client/src/sys_system.cpp
Expand Up @@ -134,9 +134,13 @@ void Sys_Shutdown()
// Let's shut down sound first, so Windows' HD-hogging doesn't jam
// the MUS player (would produce horrible bursts of notes).
S_Shutdown();

#ifdef __CLIENT__
GL_Shutdown();
ClientApp::inputSystem().clearEvents();
if(ClientApp::hasInputSystem())
{
ClientApp::inputSystem().clearEvents();
}
#endif

App_ClearGames();
Expand Down

0 comments on commit 68823ad

Please sign in to comment.