Disallow instantiating, modifying or deleting peripherals when running processor
MODIFY
src/ioperipheraltab.cpp
src/ioperipheraltab.cpp
#include "io/iomanager.h"
#include "io/periphparammodel.h"
#include "io/registermapmodel.h"
+#include "processorhandler.h"
namespace Ripes {
@@ -27,6 +28,12 @@ IOPeripheralTab::IOPeripheralTab(QWidget* parent, IOBase* peripheral)
m_ui->parameterView->setItemDelegateForColumn(PeriphParamModel::Value, new PeriphParamDelegate(this));
}
+ // Disable parameter modification during processor running
+ connect(ProcessorHandler::get(), &ProcessorHandler::runStarted, this,
+ [=] { m_ui->parameterView->setEnabled(false); });
+ connect(ProcessorHandler::get(), &ProcessorHandler::runFinished, this,
+ [=] { m_ui->parameterView->setEnabled(true); });
+
updateExportsInfo();
connect(peripheral, &IOBase::paramsChanged, this, &IOPeripheralTab::updateExportsInfo);
@@ -36,7 +43,7 @@ void IOPeripheralTab::updateExportsInfo() {
m_ui->exports->clear();
auto symbols = IOManager::get().assemblerSymbolsForPeriph(m_peripheral);
for (const auto& symbol : symbols) {
- m_ui->exports->appendPlainText("#define " + symbol.first + " " + "(0x" + QString::number(symbol.second, 16) +
+ m_ui->exports->appendPlainText("#define " + symbol.first.v + " " + "(0x" + QString::number(symbol.second, 16) +
")");
}
CSyntaxHighlighter(m_ui->exports->document()).rehighlight();

MODIFY
src/iotab.cpp
src/iotab.cpp
@@ -60,9 +60,14 @@ IOTab::IOTab(QToolBar* toolbar, QWidget* parent) : RipesTab(toolbar, parent), m_
});
connect(&IOManager::get(), &IOManager::peripheralRemoved, QPointer(this), &IOTab::removePeripheral);
-
connect(m_ui->peripheralsTab, &QTabWidget::currentChanged, this, &IOTab::setPeripheralMDIWindowActive);
+ // Disable instantiating new peripherals during processor running
+ connect(ProcessorHandler::get(), &ProcessorHandler::runStarted, this,
+ [=] { m_ui->peripheralsTable->setEnabled(false); });
+ connect(ProcessorHandler::get(), &ProcessorHandler::runFinished, this,
+ [=] { m_ui->peripheralsTable->setEnabled(true); });
+
// Store peripheral state before exiting the program
connect(RipesSettings::getObserver(RIPES_GLOBALSIGNAL_QUIT), &SettingObserver::modified, this,
&IOTab::storePeripheralState);
@@ -106,6 +111,14 @@ IOBase* IOTab::createPeripheral(IOType type, int forcedID) {
mdiw->resize(mdiw->minimumSizeHint());
});
+ mdiw->setWindowFlags(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint);
+
+ // Disable MDI subwindow close button when running the processor
+ connect(ProcessorHandler::get(), &ProcessorHandler::runStarted, mdiw,
+ [=] { mdiw->setWindowFlags(Qt::WindowTitleHint); });
+ connect(ProcessorHandler::get(), &ProcessorHandler::runFinished, mdiw,
+ [=] { mdiw->setWindowFlags(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint); });
+
m_subWindows[peripheralTab] = mdiw;
return peripheral;
}

MODIFY
src/processorhandler.cpp
src/processorhandler.cpp
@@ -242,6 +242,10 @@ void ProcessorHandler::asyncTrap() {
}
}
+bool ProcessorHandler::isRunning() {
+ return !get()->m_runWatcher.isFinished();
+}
+
void ProcessorHandler::checkProcessorFinished() {
if (m_currentProcessor->finished())
emit exit();

MODIFY
src/processorhandler.h
src/processorhandler.h
@@ -118,6 +118,7 @@ public:
bool hasBreakpoint(const uint32_t address) const;
void clearBreakpoints();
void checkProcessorFinished();
+ static bool isRunning();
/**
* @brief run

Disallow instantiating, modifying or deleting peripherals when running processor