aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2018-04-23 13:28:58 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2018-04-26 09:56:39 +0000
commit1a3447a0405831fa5502247f9eaff48afdfe0dea (patch)
treef40e71aadfda2ddc251ebab18a983a80b5d9b33f /tools
parent78be6b2aa4da54cb41ed60a31abfb7312fb44c9a (diff)
Clean up manual reference of QQmlTypeData and QQmlPropertyCache
We have a few places in the type loader where we do adventurous manual reference counting, where getType() returns a raw pointer that has been addref()'ed and then sometimes somehow we call release() later. Commit 0b394e30bba4f6bb7e6f7dbe5585a2e15aa0f21d is an example of where this can easily go wrong. As a consequence and also in preparation for future work on the type loader, this patch starts replacing the manual reference counting there. Changing the return type from QQmlTypeData *getType() to a QQmlRefPointer<> itself is not sufficient though, as the implicit operator T*() will still allow the caller to store the result as a raw pointer. Therefore this patch removes the "unsafe" implicit extraction operator. As a result of that change, other types that are sometimes stored in QQmlRefPointer are also affected and their usage needs to be adapted to QQmlRefPointer usage or manual raw pointer extraction with .data(). Change-Id: I18fd40634047f13196a237f4e6766cbef3bfbea2 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tools')
-rw-r--r--tools/qmlcachegen/qmlcachegen.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/qmlcachegen/qmlcachegen.cpp b/tools/qmlcachegen/qmlcachegen.cpp
index 97392280a4..ff3a2d9cff 100644
--- a/tools/qmlcachegen/qmlcachegen.cpp
+++ b/tools/qmlcachegen/qmlcachegen.cpp
@@ -235,7 +235,7 @@ static bool compileQmlFile(const QString &inputFileName, SaveFunction saveFuncti
unit->flags |= QV4::CompiledData::Unit::PendingTypeCompilation;
irDocument.javaScriptCompilationUnit->data = unit;
- if (!saveFunction(irDocument.javaScriptCompilationUnit, &error->message))
+ if (!saveFunction(irDocument.javaScriptCompilationUnit.data(), &error->message))
return false;
free(unit);
@@ -322,7 +322,7 @@ static bool compileJSFile(const QString &inputFileName, const QString &inputFile
unit->flags |= QV4::CompiledData::Unit::StaticData;
irDocument.javaScriptCompilationUnit->data = unit;
- if (!saveFunction(irDocument.javaScriptCompilationUnit, &error->message)) {
+ if (!saveFunction(irDocument.javaScriptCompilationUnit.data(), &error->message)) {
engine->setDirectives(oldDirs);
return false;
}