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