forked from qt-creator/qt-creator
ClangTools: Fix state of the "Apply Fixits" button
* Disable the button when (re-)running an analysis. * Ensure the button stays disabled when a file is saved. Change-Id: I1140dd3938de554ea83d33c5bb490be3468d7db0 Reviewed-by: Cristian Adam <cristian.adam@qt.io> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -495,12 +495,13 @@ void ClangTool::startTool(ClangTool::FileSelection fileSelection,
|
||||
});
|
||||
|
||||
m_perspective.select();
|
||||
|
||||
m_diagnosticModel->clear();
|
||||
|
||||
setToolBusy(true);
|
||||
m_diagnosticFilterModel->setProject(project);
|
||||
m_applyFixitsButton->setEnabled(false);
|
||||
m_running = true;
|
||||
|
||||
setToolBusy(true);
|
||||
handleStateUpdate();
|
||||
updateRunActions();
|
||||
|
||||
|
@@ -101,10 +101,10 @@ QDebug operator<<(QDebug debug, const Diagnostic &d)
|
||||
|
||||
void ClangToolsDiagnosticModel::addDiagnostics(const Diagnostics &diagnostics)
|
||||
{
|
||||
const auto onFixitStatusChanged = [this](FixitStatus newStatus) {
|
||||
const auto onFixitStatusChanged = [this](FixitStatus oldStatus, FixitStatus newStatus) {
|
||||
if (newStatus == FixitStatus::Scheduled)
|
||||
++m_fixItsToApplyCount;
|
||||
else
|
||||
else if (oldStatus == FixitStatus::Scheduled)
|
||||
--m_fixItsToApplyCount;
|
||||
emit fixItsToApplyCountChanged(m_fixItsToApplyCount);
|
||||
};
|
||||
@@ -463,7 +463,7 @@ void DiagnosticItem::setFixItStatus(const FixitStatus &status)
|
||||
m_fixitStatus = status;
|
||||
update();
|
||||
if (m_onFixitStatusChanged && status != oldStatus)
|
||||
m_onFixitStatusChanged(status);
|
||||
m_onFixitStatusChanged(oldStatus, status);
|
||||
}
|
||||
|
||||
void DiagnosticItem::setFixitOperations(const ReplacementOperations &replacements)
|
||||
|
@@ -71,8 +71,9 @@ private:
|
||||
class DiagnosticItem : public Utils::TreeItem
|
||||
{
|
||||
public:
|
||||
using OnFixitStatusChanged = std::function<void(FixitStatus newStatus)>;
|
||||
DiagnosticItem(const Diagnostic &diag, const OnFixitStatusChanged &onFixitStatusChanged,
|
||||
using OnFixitStatusChanged = std::function<void(FixitStatus oldStatus, FixitStatus newStatus)>;
|
||||
DiagnosticItem(const Diagnostic &diag,
|
||||
const OnFixitStatusChanged &onFixitStatusChanged,
|
||||
ClangToolsDiagnosticModel *parent);
|
||||
~DiagnosticItem() override;
|
||||
|
||||
|
Reference in New Issue
Block a user