Fix reset button crashing when pressed before the emu is started

This commit is contained in:
meepingsnesroms
2019-03-03 10:49:14 -08:00
parent 89e193a091
commit 930e4f314c
3 changed files with 15 additions and 47 deletions

View File

@@ -14,10 +14,6 @@
#include <string>
#include <stdint.h>
#if defined(Q_OS_ANDROID)
#include <android/log.h>
#endif
#include "emuwrapper.h"
#include "../../src/emulator.h"
@@ -36,9 +32,6 @@ char* frontendDebugString;
void frontendHandleDebugPrint(){
#if defined(Q_OS_ANDROID)
__android_log_print(ANDROID_LOG_DEBUG, "MuDebug", "%s", frontendDebugString);
#else
QString newDebugString = frontendDebugString;
//this debug handler doesnt need the \n
@@ -55,7 +48,6 @@ void frontendHandleDebugPrint(){
debugStrings.push_back(newDebugString);
duplicateCallCount.push_back(1);
}
#endif
}
@@ -263,19 +255,20 @@ void EmuWrapper::resume(){
}
void EmuWrapper::reset(bool hard){
bool wasPaused = isPaused();
if(emuInited){
bool wasPaused = isPaused();
if(!wasPaused)
pause();
if(!wasPaused)
pause();
//save here
if(hard)
emulatorHardReset();
else
emulatorSoftReset();
if(hard)
emulatorHardReset();
else
emulatorSoftReset();
if(!wasPaused)
resume();
if(!wasPaused)
resume();
}
}
uint32_t EmuWrapper::saveState(const QString& path){

View File

@@ -23,33 +23,6 @@
#include "statemanager.h"
/*
#if defined(Q_OS_ANDROID)
#include <android/log.h>
#endif
void printLastRun(){
static int64_t lastTime = 0;
struct timespec tms;
clock_gettime(CLOCK_REALTIME, &tms);
int64_t micros = tms.tv_sec * 1000000;
micros += tms.tv_nsec / 1000;
if(tms.tv_nsec % 1000 >= 500)
micros++;
#if defined(Q_OS_ANDROID)
__android_log_print(ANDROID_LOG_DEBUG, "Mu", "Microseconds:%lld\n", micros - lastTime);
#else
printf("Microseconds:%lld\n", micros - lastTime);
#endif
lastTime = micros;
}
*/
MainWindow::MainWindow(QWidget* parent) :
QMainWindow(parent),
ui(new Ui::MainWindow){
@@ -213,8 +186,6 @@ void MainWindow::updateDisplay(){
ui->display->repaint();
ui->powerButtonLed->repaint();
}
//printLastRun();
}
//Palm buttons
@@ -319,6 +290,7 @@ void MainWindow::on_ctrlBtn_clicked(){
ui->install->setEnabled(true);
ui->stateManager->setEnabled(true);
ui->debugger->setEnabled(true);
ui->reset->setEnabled(true);
ui->ctrlBtn->setIcon(QIcon(":/buttons/images/pause.svg"));
}

View File

@@ -379,6 +379,9 @@
</item>
<item row="1" column="1">
<widget class="QPushButton" name="reset">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>