forked from qt-creator/qt-creator
Aspect: Don't try to change value more than once
When our window loses focus the editingFinished signal is triggered. This can happen multiple times (QTBUG-121983) if the result of the edit is a modal dialog and the user clicks outside our application. This would call editingFinished again, resulting in multiple message boxes being opened. (Easiest to reproduce is changing the build directory of a project which displays a message box confirming the change) This patch checks, via a recursion Guard, that the slot is not already in the process of being called. Change-Id: I5e61e1b57680f0b1f2483a81682e791bfb5c0867 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
#include "checkablemessagebox.h"
|
#include "checkablemessagebox.h"
|
||||||
#include "environment.h"
|
#include "environment.h"
|
||||||
#include "fancylineedit.h"
|
#include "fancylineedit.h"
|
||||||
|
#include "guard.h"
|
||||||
#include "iconbutton.h"
|
#include "iconbutton.h"
|
||||||
#include "layoutbuilder.h"
|
#include "layoutbuilder.h"
|
||||||
#include "passworddialog.h"
|
#include "passworddialog.h"
|
||||||
@@ -1181,12 +1182,11 @@ void StringAspect::addToLayout(LayoutItem &parent)
|
|||||||
connect(lineEditDisplay, &FancyLineEdit::validChanged, this, &StringAspect::validChanged);
|
connect(lineEditDisplay, &FancyLineEdit::validChanged, this, &StringAspect::validChanged);
|
||||||
bufferToGui();
|
bufferToGui();
|
||||||
if (isAutoApply() && d->m_autoApplyOnEditingFinished) {
|
if (isAutoApply() && d->m_autoApplyOnEditingFinished) {
|
||||||
connect(lineEditDisplay,
|
connect(lineEditDisplay, &FancyLineEdit::editingFinished, this, [this, lineEditDisplay] {
|
||||||
&FancyLineEdit::editingFinished,
|
if (lineEditDisplay->text() != d->undoable.get()) {
|
||||||
this,
|
|
||||||
[this, lineEditDisplay] {
|
|
||||||
d->undoable.set(undoStack(), lineEditDisplay->text());
|
d->undoable.set(undoStack(), lineEditDisplay->text());
|
||||||
handleGuiChanged();
|
handleGuiChanged();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
connect(lineEditDisplay, &QLineEdit::textChanged, this, [this, lineEditDisplay] {
|
connect(lineEditDisplay, &QLineEdit::textChanged, this, [this, lineEditDisplay] {
|
||||||
@@ -1386,6 +1386,8 @@ public:
|
|||||||
bool m_autoApplyOnEditingFinished = false;
|
bool m_autoApplyOnEditingFinished = false;
|
||||||
bool m_allowPathFromDevice = true;
|
bool m_allowPathFromDevice = true;
|
||||||
bool m_validatePlaceHolder = false;
|
bool m_validatePlaceHolder = false;
|
||||||
|
|
||||||
|
Guard m_editFinishedGuard;
|
||||||
};
|
};
|
||||||
|
|
||||||
FilePathAspect::FilePathAspect(AspectContainer *container)
|
FilePathAspect::FilePathAspect(AspectContainer *container)
|
||||||
@@ -1559,8 +1561,12 @@ void FilePathAspect::addToLayout(Layouting::LayoutItem &parent)
|
|||||||
connect(d->m_pathChooserDisplay, &PathChooser::validChanged, this, &FilePathAspect::validChanged);
|
connect(d->m_pathChooserDisplay, &PathChooser::validChanged, this, &FilePathAspect::validChanged);
|
||||||
bufferToGui();
|
bufferToGui();
|
||||||
if (isAutoApply() && d->m_autoApplyOnEditingFinished) {
|
if (isAutoApply() && d->m_autoApplyOnEditingFinished) {
|
||||||
connect(d->m_pathChooserDisplay, &PathChooser::editingFinished,
|
connect(d->m_pathChooserDisplay, &PathChooser::editingFinished, this, [this] {
|
||||||
this, &FilePathAspect::handleGuiChanged);
|
if (d->m_editFinishedGuard.isLocked())
|
||||||
|
return;
|
||||||
|
GuardLocker lk(d->m_editFinishedGuard);
|
||||||
|
handleGuiChanged();
|
||||||
|
});
|
||||||
connect(d->m_pathChooserDisplay, &PathChooser::browsingFinished,
|
connect(d->m_pathChooserDisplay, &PathChooser::browsingFinished,
|
||||||
this, &FilePathAspect::handleGuiChanged);
|
this, &FilePathAspect::handleGuiChanged);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user