forked from qt-creator/qt-creator
McuSupport: disable run button while flashing in progress
Mcus run configuration will build and flash the binary into the target board. The flash process could go wrong if the user accidentally restarted the flashing process by clicking the run button again while flashing is already in progress. Task-number: QTMCU-104 Change-Id: I1387bfd1dd299d427af13de5904f5ad3a8a1d347 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
committed by
Yasser Grimes
parent
5e0c97a38e
commit
eb45df8349
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <projectexplorer/buildconfiguration.h>
|
#include <projectexplorer/buildconfiguration.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
|
#include <projectexplorer/projectexplorer.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
|
|
||||||
@@ -58,9 +59,20 @@ public:
|
|||||||
connect(target->project(), &Project::displayNameChanged, this, &RunConfiguration::update);
|
connect(target->project(), &Project::displayNameChanged, this, &RunConfiguration::update);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isEnabled() const override
|
||||||
|
{
|
||||||
|
if (disabled)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return RunConfiguration::isEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool disabled;
|
||||||
StringAspect flashAndRunParameters{this};
|
StringAspect flashAndRunParameters{this};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool FlashAndRunConfiguration::disabled = false;
|
||||||
|
|
||||||
class FlashAndRunWorker : public SimpleTargetRunner
|
class FlashAndRunWorker : public SimpleTargetRunner
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -74,6 +86,15 @@ public:
|
|||||||
setWorkingDirectory(target->activeBuildConfiguration()->buildDirectory());
|
setWorkingDirectory(target->activeBuildConfiguration()->buildDirectory());
|
||||||
setEnvironment(target->activeBuildConfiguration()->environment());
|
setEnvironment(target->activeBuildConfiguration()->environment());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connect(runControl, &RunControl::started, []() {
|
||||||
|
FlashAndRunConfiguration::disabled = true;
|
||||||
|
ProjectExplorerPlugin::updateRunActions();
|
||||||
|
});
|
||||||
|
connect(runControl, &RunControl::stopped, []() {
|
||||||
|
FlashAndRunConfiguration::disabled = false;
|
||||||
|
ProjectExplorerPlugin::updateRunActions();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user