aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/common/qv4compileddata_p.h3
-rw-r--r--tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp15
2 files changed, 17 insertions, 1 deletions
diff --git a/src/qml/common/qv4compileddata_p.h b/src/qml/common/qv4compileddata_p.h
index 381a5735d3..231cd16d68 100644
--- a/src/qml/common/qv4compileddata_p.h
+++ b/src/qml/common/qv4compileddata_p.h
@@ -1330,7 +1330,8 @@ public:
template<typename Char>
bool saveToDisk(const std::function<bool(const Char *, quint32)> &writer) const
{
- auto cleanup = qScopeGuard([this]() { mutableFlags() ^= temporaryFlags; });
+ const quint32_le oldFlags = mutableFlags();
+ auto cleanup = qScopeGuard([this, oldFlags]() { mutableFlags() = oldFlags; });
mutableFlags() |= temporaryFlags;
return writer(data<Char>(), size());
}
diff --git a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
index 3810f505b3..65137c65a2 100644
--- a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
+++ b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
@@ -37,6 +37,7 @@
#include <QLoggingCategory>
#include <private/qqmlcomponent_p.h>
#include <private/qqmlscriptdata_p.h>
+#include <private/qv4compileddata_p.h>
#include <qtranslator.h>
#include "../../shared/util.h"
@@ -78,6 +79,8 @@ private slots:
void parameterAdjustment();
void inlineComponent();
void posthocRequired();
+
+ void saveableUnitPointer();
};
// A wrapper around QQmlComponent to ensure the temporary reference counts
@@ -713,6 +716,18 @@ void tst_qmlcachegen::posthocRequired()
QVERIFY(component.errorString().contains(QStringLiteral("Required property x was not initialized")));
}
+void tst_qmlcachegen::saveableUnitPointer()
+{
+ QV4::CompiledData::Unit unit;
+ unit.flags = QV4::CompiledData::Unit::StaticData | QV4::CompiledData::Unit::IsJavascript;
+ const auto flags = unit.flags;
+
+ QV4::CompiledData::SaveableUnitPointer pointer(&unit);
+
+ QVERIFY(pointer.saveToDisk<char>([](const char *, quint32) { return true; }));
+ QCOMPARE(unit.flags, flags);
+}
+
QTEST_GUILESS_MAIN(tst_qmlcachegen)
#include "tst_qmlcachegen.moc"