forked from qt-creator/qt-creator
QmlDesigner: unlock model when resetting in rewriter
We have to unlock the model to revert the model to the last correct state. The unlock method is not supposed to be used elsewhere and hidden in a private header. Fixing miss leading warning in destructor. Change-Id: Ia14aab2a8ffdc1cb9fa9b2968cdef38bfc84e5d5 Reviewed-by: Henning Gründl <henning.gruendl@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -1387,12 +1387,22 @@ WriteLocker::WriteLocker(Model *model)
|
||||
WriteLocker::~WriteLocker()
|
||||
{
|
||||
if (!m_model->m_writeLock)
|
||||
qWarning() << "QmlDesigner: Misbehaving view calls back to model!!!";
|
||||
qWarning() << "QmlDesigner: WriterLocker out of sync!!!";
|
||||
// FIXME: Enable it again
|
||||
Q_ASSERT(m_model->m_writeLock);
|
||||
m_model->m_writeLock = false;
|
||||
}
|
||||
|
||||
void WriteLocker::unlock(Model *model)
|
||||
{
|
||||
model->d->m_writeLock = false;
|
||||
}
|
||||
|
||||
void WriteLocker::lock(Model *model)
|
||||
{
|
||||
model->d->m_writeLock = true;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Model::Model()
|
||||
|
@@ -78,6 +78,9 @@ public:
|
||||
WriteLocker(ModelPrivate *model);
|
||||
~WriteLocker();
|
||||
|
||||
static void unlock(Model *model);
|
||||
static void lock(Model *model);
|
||||
|
||||
private:
|
||||
QPointer<ModelPrivate> m_model;
|
||||
};
|
||||
|
@@ -28,17 +28,18 @@
|
||||
#include "texttomodelmerger.h"
|
||||
#include "modeltotextmerger.h"
|
||||
|
||||
#include <variantproperty.h>
|
||||
#include <bindingproperty.h>
|
||||
#include <customnotifications.h>
|
||||
#include <filemanager/astobjecttextextractor.h>
|
||||
#include <filemanager/firstdefinitionfinder.h>
|
||||
#include <filemanager/objectlengthcalculator.h>
|
||||
#include <model_p.h>
|
||||
#include <modelnode.h>
|
||||
#include <modelnodepositionstorage.h>
|
||||
#include <nodeproperty.h>
|
||||
#include <rewritingexception.h>
|
||||
#include <signalhandlerproperty.h>
|
||||
#include <filemanager/astobjecttextextractor.h>
|
||||
#include <filemanager/objectlengthcalculator.h>
|
||||
#include <filemanager/firstdefinitionfinder.h>
|
||||
#include <customnotifications.h>
|
||||
#include <modelnodepositionstorage.h>
|
||||
#include <modelnode.h>
|
||||
#include <nodeproperty.h>
|
||||
#include <variantproperty.h>
|
||||
#include <qmlobjectnode.h>
|
||||
#include <qmltimelinekeyframegroup.h>
|
||||
|
||||
@@ -799,7 +800,9 @@ void RewriterView::resetToLastCorrectQml()
|
||||
m_textModifier->textDocument()->undo();
|
||||
m_textModifier->textDocument()->clearUndoRedoStacks(QTextDocument::RedoStack);
|
||||
ModelAmender differenceHandler(m_textToModelMerger.data());
|
||||
Internal::WriteLocker::unlock(model());
|
||||
m_textToModelMerger->load(m_textModifier->text(), differenceHandler);
|
||||
Internal::WriteLocker::lock(model());
|
||||
|
||||
leaveErrorState();
|
||||
}
|
||||
|
Reference in New Issue
Block a user