Replaced nasty onInsightStateChangedEvent event handler in TargetController with new GetTargetState command
This commit is contained in:
@@ -139,11 +139,16 @@ namespace Bloom
|
|||||||
QObject::connect(eventDispatchTimer, &QTimer::timeout, this, &Insight::dispatchEvents);
|
QObject::connect(eventDispatchTimer, &QTimer::timeout, this, &Insight::dispatchEvents);
|
||||||
eventDispatchTimer->start(100);
|
eventDispatchTimer->start(100);
|
||||||
|
|
||||||
|
QObject::connect(
|
||||||
|
this->mainWindow,
|
||||||
|
&InsightWindow::activatedSignal,
|
||||||
|
this->insightWorker,
|
||||||
|
&InsightWorker::onInsightWindowActivated
|
||||||
|
);
|
||||||
|
|
||||||
this->mainWindow->setInsightConfig(this->insightConfig);
|
this->mainWindow->setInsightConfig(this->insightConfig);
|
||||||
this->mainWindow->setEnvironmentConfig(this->environmentConfig);
|
this->mainWindow->setEnvironmentConfig(this->environmentConfig);
|
||||||
|
|
||||||
this->mainWindow->init(targetDescriptor);
|
|
||||||
|
|
||||||
// Prepare worker thread
|
// Prepare worker thread
|
||||||
this->workerThread = new QThread();
|
this->workerThread = new QThread();
|
||||||
this->workerThread->setObjectName("IW");
|
this->workerThread->setObjectName("IW");
|
||||||
@@ -152,6 +157,8 @@ namespace Bloom
|
|||||||
QObject::connect(this->workerThread, &QThread::finished, this->insightWorker, &QObject::deleteLater);
|
QObject::connect(this->workerThread, &QThread::finished, this->insightWorker, &QObject::deleteLater);
|
||||||
QObject::connect(this->workerThread, &QThread::finished, this->workerThread, &QThread::deleteLater);
|
QObject::connect(this->workerThread, &QThread::finished, this->workerThread, &QThread::deleteLater);
|
||||||
|
|
||||||
|
this->mainWindow->init(targetDescriptor);
|
||||||
|
|
||||||
QObject::connect(this->insightWorker, &InsightWorker::ready, this, [this] {
|
QObject::connect(this->insightWorker, &InsightWorker::ready, this, [this] {
|
||||||
this->checkBloomVersion();
|
this->checkBloomVersion();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -58,6 +58,11 @@ namespace Bloom
|
|||||||
emit this->ready();
|
emit this->ready();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InsightWorker::onInsightWindowActivated() {
|
||||||
|
this->lastTargetState = this->targetControllerConsole.getTargetState();
|
||||||
|
emit this->targetStateUpdated(this->lastTargetState);
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<InsightWorkerTask*> InsightWorker::getQueuedTask() {
|
std::optional<InsightWorkerTask*> InsightWorker::getQueuedTask() {
|
||||||
auto task = std::optional<InsightWorkerTask*>();
|
auto task = std::optional<InsightWorkerTask*>();
|
||||||
|
|
||||||
|
|||||||
@@ -30,12 +30,10 @@ namespace Bloom
|
|||||||
|
|
||||||
void queueTask(InsightWorkerTask* task);
|
void queueTask(InsightWorkerTask* task);
|
||||||
|
|
||||||
void dispatchEvents() {
|
|
||||||
this->eventListener->dispatchCurrentEvents();
|
|
||||||
}
|
|
||||||
|
|
||||||
void startup();
|
void startup();
|
||||||
|
|
||||||
|
void onInsightWindowActivated();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void ready();
|
void ready();
|
||||||
void taskQueued();
|
void taskQueued();
|
||||||
@@ -58,6 +56,10 @@ namespace Bloom
|
|||||||
|
|
||||||
SyncSafe<std::queue<InsightWorkerTask*>> queuedTasks;
|
SyncSafe<std::queue<InsightWorkerTask*>> queuedTasks;
|
||||||
|
|
||||||
|
void dispatchEvents() {
|
||||||
|
this->eventListener->dispatchCurrentEvents();
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<InsightWorkerTask*> getQueuedTask();
|
std::optional<InsightWorkerTask*> getQueuedTask();
|
||||||
|
|
||||||
void onTargetStoppedEvent(const Events::TargetExecutionStopped& event);
|
void onTargetStoppedEvent(const Events::TargetExecutionStopped& event);
|
||||||
|
|||||||
@@ -347,6 +347,7 @@ namespace Bloom
|
|||||||
|
|
||||||
this->setUiDisabled(this->targetState != TargetState::STOPPED);
|
this->setUiDisabled(this->targetState != TargetState::STOPPED);
|
||||||
this->activated = true;
|
this->activated = true;
|
||||||
|
emit this->activatedSignal();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InsightWindow::populateVariantMenu() {
|
void InsightWindow::populateVariantMenu() {
|
||||||
|
|||||||
@@ -50,6 +50,9 @@ namespace Bloom
|
|||||||
|
|
||||||
void init(Targets::TargetDescriptor targetDescriptor);
|
void init(Targets::TargetDescriptor targetDescriptor);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void activatedSignal();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent* event) override;
|
void resizeEvent(QResizeEvent* event) override;
|
||||||
void showEvent(QShowEvent* event) override;
|
void showEvent(QShowEvent* event) override;
|
||||||
|
|||||||
@@ -243,6 +243,10 @@ void TargetMemoryInspectionPane::sanitiseSettings() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TargetMemoryInspectionPane::onTargetStateChanged(Targets::TargetState newState) {
|
void TargetMemoryInspectionPane::onTargetStateChanged(Targets::TargetState newState) {
|
||||||
|
if (this->targetState == newState) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
using Targets::TargetState;
|
using Targets::TargetState;
|
||||||
this->targetState = newState;
|
this->targetState = newState;
|
||||||
|
|
||||||
|
|||||||
@@ -261,6 +261,10 @@ namespace Bloom::Widgets
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TargetRegisterInspectorWindow::onTargetStateChanged(TargetState newState) {
|
void TargetRegisterInspectorWindow::onTargetStateChanged(TargetState newState) {
|
||||||
|
if (this->targetState == newState) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (newState != TargetState::STOPPED) {
|
if (newState != TargetState::STOPPED) {
|
||||||
this->registerValueTextInput->setDisabled(true);
|
this->registerValueTextInput->setDisabled(true);
|
||||||
this->registerValueBitsetWidgetContainer->setDisabled(true);
|
this->registerValueBitsetWidgetContainer->setDisabled(true);
|
||||||
|
|||||||
@@ -231,6 +231,10 @@ namespace Bloom::Widgets
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TargetRegistersPaneWidget::onTargetStateChanged(Targets::TargetState newState) {
|
void TargetRegistersPaneWidget::onTargetStateChanged(Targets::TargetState newState) {
|
||||||
|
if (this->targetState == newState) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
using Targets::TargetState;
|
using Targets::TargetState;
|
||||||
this->targetState = newState;
|
this->targetState = newState;
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,10 @@ namespace Bloom::Widgets::InsightTargetWidgets
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TargetPackageWidget::onTargetStateChanged(TargetState newState) {
|
void TargetPackageWidget::onTargetStateChanged(TargetState newState) {
|
||||||
|
if (this->targetState == newState) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this->targetState = newState;
|
this->targetState = newState;
|
||||||
|
|
||||||
if (newState == TargetState::RUNNING) {
|
if (newState == TargetState::RUNNING) {
|
||||||
|
|||||||
@@ -922,19 +922,6 @@ namespace Bloom::TargetController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove this
|
|
||||||
void TargetControllerComponent::onInsightStateChangedEvent(const Events::InsightThreadStateChanged& event) {
|
|
||||||
if (event.getState() == ThreadState::READY) {
|
|
||||||
/*
|
|
||||||
* Insight has just started up.
|
|
||||||
*
|
|
||||||
* Refresh the target state and kick off a target stop/resume execution event. Setting the lastTargetState
|
|
||||||
* to UNKNOWN will be enough to do this. See TargetControllerComponent::fireTargetEvents().
|
|
||||||
*/
|
|
||||||
this->lastTargetState = TargetState::UNKNOWN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TargetControllerComponent::onRetrieveTargetPinStatesEvent(const Events::RetrieveTargetPinStates& event) {
|
void TargetControllerComponent::onRetrieveTargetPinStatesEvent(const Events::RetrieveTargetPinStates& event) {
|
||||||
try {
|
try {
|
||||||
if (this->target->getState() != TargetState::STOPPED) {
|
if (this->target->getState() != TargetState::STOPPED) {
|
||||||
|
|||||||
@@ -341,14 +341,6 @@ namespace Bloom::TargetController
|
|||||||
*/
|
*/
|
||||||
void onSetProgramCounterEvent(const Events::SetProgramCounterOnTarget& event);
|
void onSetProgramCounterEvent(const Events::SetProgramCounterOnTarget& event);
|
||||||
|
|
||||||
/**
|
|
||||||
* Will automatically fire a target state update event.
|
|
||||||
* @TODO: get rid of this - Insight should request this itself.
|
|
||||||
*
|
|
||||||
* @param event
|
|
||||||
*/
|
|
||||||
void onInsightStateChangedEvent(const Events::InsightThreadStateChanged& event);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will attempt to obtain the pin states from the target. Will emit a TargetPinStatesRetrieved event on success.
|
* Will attempt to obtain the pin states from the target. Will emit a TargetPinStatesRetrieved event on success.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user