summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-04-20 10:05:39 +1000
committerMartin Jones <martin.jones@nokia.com>2010-04-20 10:05:39 +1000
commit1b80a6bc28cb49b9f6e1a2132d929819924aa604 (patch)
treed0de1b7639a4b9259af5b97488e339f604f83e46 /src
parent18cbadd8edd233b843d04441a05788264da0a67b (diff)
downloadqt4-tools-1b80a6bc28cb49b9f6e1a2132d929819924aa604.tar.gz
Allow Loader sourceComponent to be set to undefeined.
Diffstat (limited to 'src')
-rw-r--r--src/declarative/graphicsitems/qdeclarativeloader.cpp10
-rw-r--r--src/declarative/graphicsitems/qdeclarativeloader_p.h3
2 files changed, 11 insertions, 2 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp
index 3f257b5362..bdd2c877db 100644
--- a/src/declarative/graphicsitems/qdeclarativeloader.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp
@@ -132,12 +132,15 @@ void QDeclarativeLoaderPrivate::initResize()
\endcode
If the Loader source is changed, any previous items instantiated
- will be destroyed. Setting \c source to an empty string
+ will be destroyed. Setting \c source to an empty string, or setting
+ sourceComponent to \e undefined
will destroy the currently instantiated items, freeing resources
and leaving the Loader empty. For example:
\code
pageLoader.source = ""
+ or
+ pageLoader.sourceComponent = undefined
\endcode
unloads "Page1.qml" and frees resources consumed by it.
@@ -271,6 +274,11 @@ void QDeclarativeLoader::setSourceComponent(QDeclarativeComponent *comp)
}
}
+void QDeclarativeLoader::resetSourceComponent()
+{
+ setSourceComponent(0);
+}
+
void QDeclarativeLoaderPrivate::_q_sourceLoaded()
{
Q_Q(QDeclarativeLoader);
diff --git a/src/declarative/graphicsitems/qdeclarativeloader_p.h b/src/declarative/graphicsitems/qdeclarativeloader_p.h
index 65538a8d8b..e9fd8e9502 100644
--- a/src/declarative/graphicsitems/qdeclarativeloader_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeloader_p.h
@@ -58,7 +58,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeLoader : public QDeclarativeItem
Q_ENUMS(ResizeMode)
Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
- Q_PROPERTY(QDeclarativeComponent *sourceComponent READ sourceComponent WRITE setSourceComponent NOTIFY sourceChanged)
+ Q_PROPERTY(QDeclarativeComponent *sourceComponent READ sourceComponent WRITE setSourceComponent RESET resetSourceComponent NOTIFY sourceChanged)
Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode NOTIFY resizeModeChanged)
Q_PROPERTY(QGraphicsObject *item READ item NOTIFY itemChanged)
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
@@ -73,6 +73,7 @@ public:
QDeclarativeComponent *sourceComponent() const;
void setSourceComponent(QDeclarativeComponent *);
+ void resetSourceComponent();
enum Status { Null, Ready, Loading, Error };
Status status() const;