forked from qt-creator/qt-creator
QmlJS: Add refcounting to FakeMetaObjects.
Previously they were leaked when a qmldump or the C++ exported QML type list updated. Just deleting the previous FakeMetaObjects is not an option, as they might still be used in a QmlObjectValue owned by an Engine. Reviewed-by: Erik Verbruggen
This commit is contained in:
@@ -126,15 +126,15 @@ static QString qmldumpFailedMessage()
|
||||
return PluginDumper::tr("Type dump of C++ plugin failed.\nCheck 'General Messages' output pane for details.");
|
||||
}
|
||||
|
||||
static QList<const FakeMetaObject *> parseHelper(const QByteArray &xml, QString *error)
|
||||
static QList<FakeMetaObject::ConstPtr> parseHelper(const QByteArray &xml, QString *error)
|
||||
{
|
||||
QList<const FakeMetaObject *> ret;
|
||||
QMap<QString, FakeMetaObject *> newObjects;
|
||||
QList<FakeMetaObject::ConstPtr> ret;
|
||||
QMap<QString, FakeMetaObject::Ptr> newObjects;
|
||||
*error = Interpreter::CppQmlTypesLoader::parseQmlTypeXml(xml, &newObjects);
|
||||
|
||||
if (error->isEmpty()) {
|
||||
// convert from QList<T *> to QList<const T *>
|
||||
QMapIterator<QString, FakeMetaObject *> it(newObjects);
|
||||
QMapIterator<QString, FakeMetaObject::Ptr> it(newObjects);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
ret.append(it.value());
|
||||
@@ -162,7 +162,7 @@ void PluginDumper::qmlPluginTypeDumpDone(int exitCode)
|
||||
|
||||
const QByteArray output = process->readAllStandardOutput();
|
||||
QString error;
|
||||
QList<const FakeMetaObject *> objectsList = parseHelper(output, &error);
|
||||
QList<FakeMetaObject::ConstPtr> objectsList = parseHelper(output, &error);
|
||||
if (exitCode == 0 && !error.isEmpty()) {
|
||||
libraryInfo.setDumpStatus(LibraryInfo::DumpError, tr("Type dump of C++ plugin failed. Parse error:\n'%1'").arg(error));
|
||||
}
|
||||
@@ -229,7 +229,7 @@ void PluginDumper::dump(const Plugin &plugin)
|
||||
libraryXmlFile.close();
|
||||
|
||||
QString error;
|
||||
const QList<const FakeMetaObject *> objectsList = parseHelper(xml, &error);
|
||||
const QList<FakeMetaObject::ConstPtr> objectsList = parseHelper(xml, &error);
|
||||
|
||||
if (error.isEmpty()) {
|
||||
libraryInfo.setMetaObjects(objectsList);
|
||||
|
||||
Reference in New Issue
Block a user