Qt: Fix crash when clicking on the screen with no game loaded

This commit is contained in:
Vicki Pfau 2017-04-06 11:49:58 -07:00
parent 3c85f40a8f
commit 2fa3b3089a
1 changed files with 9 additions and 0 deletions

View File

@ -698,6 +698,9 @@ void Window::dropEvent(QDropEvent* event) {
} }
void Window::mouseMoveEvent(QMouseEvent* event) { void Window::mouseMoveEvent(QMouseEvent* event) {
if (!m_controller->isLoaded()) {
return;
}
QPoint pos = event->pos(); QPoint pos = event->pos();
pos = m_screenWidget->mapFrom(this, pos); pos = m_screenWidget->mapFrom(this, pos);
QSize dimensions = m_controller->screenDimensions(); QSize dimensions = m_controller->screenDimensions();
@ -713,6 +716,9 @@ void Window::mousePressEvent(QMouseEvent* event) {
if (event->button() != Qt::LeftButton) { if (event->button() != Qt::LeftButton) {
return; return;
} }
if (!m_controller->isLoaded()) {
return;
}
mouseMoveEvent(event); mouseMoveEvent(event);
m_controller->cursorDown(true); m_controller->cursorDown(true);
} }
@ -721,6 +727,9 @@ void Window::mouseReleaseEvent(QMouseEvent* event) {
if (event->button() != Qt::LeftButton) { if (event->button() != Qt::LeftButton) {
return; return;
} }
if (!m_controller->isLoaded()) {
return;
}
mouseMoveEvent(event); mouseMoveEvent(event);
m_controller->cursorDown(false); m_controller->cursorDown(false);
} }