make sure it doesn't crash if you click the window while nothing is loaded

This commit is contained in:
Arisotura 2024-10-30 23:39:17 +01:00
parent 4ba8f330c4
commit 6dc396741f
1 changed files with 5 additions and 0 deletions

View File

@ -222,6 +222,7 @@ void ScreenPanel::resizeEvent(QResizeEvent* event)
void ScreenPanel::mousePressEvent(QMouseEvent* event) void ScreenPanel::mousePressEvent(QMouseEvent* event)
{ {
event->accept(); event->accept();
if (!emuInstance->emuIsActive()) { touching = false; return; }
if (event->button() != Qt::LeftButton) return; if (event->button() != Qt::LeftButton) return;
int x = event->pos().x(); int x = event->pos().x();
@ -238,6 +239,7 @@ void ScreenPanel::mousePressEvent(QMouseEvent* event)
void ScreenPanel::mouseReleaseEvent(QMouseEvent* event) void ScreenPanel::mouseReleaseEvent(QMouseEvent* event)
{ {
event->accept(); event->accept();
if (!emuInstance->emuIsActive()) { touching = false; return; }
if (event->button() != Qt::LeftButton) return; if (event->button() != Qt::LeftButton) return;
if (touching) if (touching)
@ -254,6 +256,7 @@ void ScreenPanel::mouseMoveEvent(QMouseEvent* event)
showCursor(); showCursor();
if (!emuInstance->emuIsActive()) return;
//if (!(event->buttons() & Qt::LeftButton)) return; //if (!(event->buttons() & Qt::LeftButton)) return;
if (!touching) return; if (!touching) return;
@ -270,6 +273,7 @@ void ScreenPanel::mouseMoveEvent(QMouseEvent* event)
void ScreenPanel::tabletEvent(QTabletEvent* event) void ScreenPanel::tabletEvent(QTabletEvent* event)
{ {
event->accept(); event->accept();
if (!emuInstance->emuIsActive()) { touching = false; return; }
switch(event->type()) switch(event->type())
{ {
@ -313,6 +317,7 @@ void ScreenPanel::touchEvent(QTouchEvent* event)
#endif #endif
event->accept(); event->accept();
if (!emuInstance->emuIsActive()) { touching = false; return; }
switch(event->type()) switch(event->type())
{ {