diff options
author | Alan Alpert <aalpert@rim.com> | 2013-01-24 14:07:29 -0800 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-05-07 19:41:28 +0200 |
commit | 9b5a55101d7c519446c1cf3706a235dea81ad4de (patch) | |
tree | 8f7201f04f8e593c8e00fd4d293d2d28e1a655ab /tests/manual/qmltypememory/TestPlugin | |
parent | 223313479bf8ec80158ba0f6cba4dd5e74d92718 (diff) |
Add qmlClearRegisteredTypes Function
Registered types are stored in a global static variable, not on an
engine instance. For applications managing multiple engines over their
lifetime, there needs to be a way to clear the existing types so they
can register new ones and avoid memory leaks.
Task-Number: QTBUG-28572
Change-Id: Ic70a4dd1e29d99399b21fb42eaf10d4a52bf2adf
Reviewed-by: Christopher Adams <chris.adams@jollamobile.com>
Diffstat (limited to 'tests/manual/qmltypememory/TestPlugin')
-rw-r--r-- | tests/manual/qmltypememory/TestPlugin/plugin.cpp | 63 | ||||
-rw-r--r-- | tests/manual/qmltypememory/TestPlugin/plugin.pro | 7 | ||||
-rw-r--r-- | tests/manual/qmltypememory/TestPlugin/qmldir | 2 |
3 files changed, 72 insertions, 0 deletions
diff --git a/tests/manual/qmltypememory/TestPlugin/plugin.cpp b/tests/manual/qmltypememory/TestPlugin/plugin.cpp new file mode 100644 index 0000000000..40c2af20f5 --- /dev/null +++ b/tests/manual/qmltypememory/TestPlugin/plugin.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Research In Motion. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtQml/QQmlExtensionPlugin> +#include <QtQml/qqml.h> +#include <qdebug.h> + +class TestType : public QObject +{ + Q_OBJECT +}; + +class TestPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + +public: + void registerTypes(const char *uri) + { + Q_ASSERT(uri == QLatin1String("TestPlugin")); + qmlRegisterType<TestType>(uri, 1, 0, "TestTypePlugin"); + } +}; + +#include "plugin.moc" diff --git a/tests/manual/qmltypememory/TestPlugin/plugin.pro b/tests/manual/qmltypememory/TestPlugin/plugin.pro new file mode 100644 index 0000000000..7575442800 --- /dev/null +++ b/tests/manual/qmltypememory/TestPlugin/plugin.pro @@ -0,0 +1,7 @@ +TEMPLATE = lib +CONFIG += plugin +QT += qml + +TARGET = testplugin + +SOURCES += plugin.cpp diff --git a/tests/manual/qmltypememory/TestPlugin/qmldir b/tests/manual/qmltypememory/TestPlugin/qmldir new file mode 100644 index 0000000000..f0624dfd82 --- /dev/null +++ b/tests/manual/qmltypememory/TestPlugin/qmldir @@ -0,0 +1,2 @@ +module TestPlugin +plugin testplugin |