Skip to content

Commit

Permalink
Fixed|UI|Client: Closing the window first unloads the game
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Nov 12, 2016
1 parent 5aadede commit ccd2667
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
6 changes: 3 additions & 3 deletions doomsday/apps/client/include/ui/clientwindow.h
Expand Up @@ -167,9 +167,6 @@ class ClientWindow : public de::BaseWindow
// Notifications.
bool isFPSCounterVisible() const;

// Events.
//void closeEvent(QCloseEvent *) override;

// Implements BaseWindow.
de::Vector2f windowContentSize() const override;
void drawWindowContent() override;
Expand All @@ -185,6 +182,9 @@ public slots:
void showColorAdjustments();
void hideTaskBarBlur();

protected:
void windowAboutToClose() override;

private:
DENG2_PRIVATE(d)
};
Expand Down
25 changes: 19 additions & 6 deletions doomsday/apps/client/src/ui/clientwindow.cpp
Expand Up @@ -441,8 +441,6 @@ DENG2_PIMPL(ClientWindow)

void windowInit(GLWindow &)
{
qDebug() << "Client: windowInit";

Sys_GLConfigureDefaultState();
GL_Init2DState();

Expand Down Expand Up @@ -869,9 +867,23 @@ bool ClientWindow::isGameMinimized() const
return d->isGameMini;
}

/*
void ClientWindow::closeEvent(QCloseEvent *ev)
void ClientWindow::windowAboutToClose()
{
if (BusyMode_Active())
{
// Oh well, we can't cancel busy mode...
return;
}

// Unload the game currently loaded. This will ensure it is shut down gracefully.
if (!DoomsdayApp::game().isNull())
{
glActivate();
BusyMode_FreezeGameForBusyMode();
DoomsdayApp::app().changeGame(GameProfiles::null(), DD_ActivateGameWorker);
}

#if 0
if (!BusyMode_Active())
{
LOG_DEBUG("Window is about to close, executing 'quit'");
Expand All @@ -882,8 +894,9 @@ void ClientWindow::closeEvent(QCloseEvent *ev)

// We are not authorizing immediate closing of the window;
// engine shutdown will take care of it later.
ev->ignore(); // don't close
}*/
return false;
#endif
}

void ClientWindow::preDraw()
{
Expand Down
1 change: 1 addition & 0 deletions doomsday/sdk/libgui/include/de/gui/glwindow.h
Expand Up @@ -181,6 +181,7 @@ class LIBGUI_PUBLIC GLWindow : public QOpenGLWindow, public Asset
protected:
void initializeGL() override;
void paintGL() override;
virtual void windowAboutToClose();

// Native events.
void resizeEvent (QResizeEvent *ev) override;
Expand Down
7 changes: 7 additions & 0 deletions doomsday/sdk/libgui/src/glwindow.cpp
Expand Up @@ -335,6 +335,10 @@ bool GLWindow::event(QEvent *ev)
return QApplication::sendEvent(&canvas(), &keyEvent);
}
#endif*/
if (ev->type() == QEvent::Close)
{
windowAboutToClose();
}
return QOpenGLWindow::event(ev);
}

Expand Down Expand Up @@ -449,6 +453,9 @@ void GLWindow::paintGL()
}
}

void GLWindow::windowAboutToClose()
{}

void GLWindow::resizeEvent(QResizeEvent *ev)
{
d->pendingSize = Size(ev->size().width(), ev->size().height()) * qApp->devicePixelRatio();
Expand Down

0 comments on commit ccd2667

Please sign in to comment.