src/declarative/qml/qdeclarativeengine.cpp
changeset 37 758a864f9613
parent 33 3e2da88830cd
equal deleted inserted replaced
36:ef0373b55136 37:758a864f9613
   112 
   112 
   113 QT_BEGIN_NAMESPACE
   113 QT_BEGIN_NAMESPACE
   114 
   114 
   115 /*!
   115 /*!
   116   \qmlclass QtObject QObject
   116   \qmlclass QtObject QObject
       
   117   \ingroup qml-utility-elements
   117   \since 4.7
   118   \since 4.7
   118   \brief The QtObject element is the most basic element in QML.
   119   \brief The QtObject element is the most basic element in QML.
   119 
   120 
   120   The QtObject element is a non-visual element which contains only the
   121   The QtObject element is a non-visual element which contains only the
   121   objectName property. 
   122   objectName property. 
   182 
   183 
   183     qmlRegisterType<QDeclarativeBinding>();
   184     qmlRegisterType<QDeclarativeBinding>();
   184 }
   185 }
   185 
   186 
   186 /*!
   187 /*!
       
   188 \qmlclass QML:Qt QDeclarativeEnginePrivate
       
   189   \ingroup qml-utility-elements
       
   190 \brief The QML global Qt object provides useful enums and functions from Qt.
       
   191 
   187 \keyword QmlGlobalQtObject
   192 \keyword QmlGlobalQtObject
   188 \qmlclass Qt QDeclarativeEnginePrivate
   193 
   189 \brief The QML global Qt object provides useful enums and functions from Qt.
   194 \brief The \c Qt object provides useful enums and functions from Qt, for use in all QML files. 
   190 
       
   191 The \c Qt object provides useful enums and functions from Qt, for use in all QML files. 
       
   192 
   195 
   193 The \c Qt object is not a QML element; it cannot be instantiated. It is a global object 
   196 The \c Qt object is not a QML element; it cannot be instantiated. It is a global object 
   194 with enums and functions.  To use it, call the members of the global \c Qt object directly. 
   197 with enums and functions.  To use it, call the members of the global \c Qt object directly. 
   195 For example:
   198 For example:
   196 
   199 
   204 \endqml
   207 \endqml
   205 
   208 
   206 
   209 
   207 \section1 Enums
   210 \section1 Enums
   208 
   211 
   209 The Qt object contains all enums in the Qt namespace. For example, you can
   212 The Qt object contains enums that declared into Qt's Meta-Object System. For example, you can access
   210 access the \c AlignLeft member of the \c Qt::AlignmentFlag enum with \c Qt.AlignLeft.
   213 the \c Leftbutton member of the \c Qt::MouseButton enum with \c Qt.LeftButton.
   211 
   214 
   212 For a full list of enums, see the \l{Qt Namespace} documentation.
       
   213 
   215 
   214 \section1 Types
   216 \section1 Types
   215 The Qt object also contains helper functions for creating objects of specific
   217 The Qt object also contains helper functions for creating objects of specific
   216 data types. This is primarily useful when setting the properties of an item
   218 data types. This is primarily useful when setting the properties of an item
   217 when the property has one of the following types:
   219 when the property has one of the following types:
   226 
   228 
   227 There are also string based constructors for these types. See \l{qdeclarativebasictypes.html}{QML Basic Types} for more information.
   229 There are also string based constructors for these types. See \l{qdeclarativebasictypes.html}{QML Basic Types} for more information.
   228 
   230 
   229 \section1 Date/Time Formatters
   231 \section1 Date/Time Formatters
   230 
   232 
   231 The Qt object contains several functions for formatting dates and times.
   233 The Qt object contains several functions for formatting QDateTime, QDate and QTime values.
   232 
   234 
   233 \list
   235 \list
   234     \o \l{QML:Qt::formatDateTime}{string Qt.formatDateTime(datetime date, variant format)}
   236     \o \l{QML:Qt::formatDateTime}{string Qt.formatDateTime(datetime date, variant format)}
   235     \o \l{QML:Qt::formatDate}{string Qt.formatDate(datetime date, variant format)}
   237     \o \l{QML:Qt::formatDate}{string Qt.formatDate(datetime date, variant format)}
   236     \o \l{QML:Qt::formatTime}{string Qt.formatTime(datetime date, variant format)}
   238     \o \l{QML:Qt::formatTime}{string Qt.formatTime(datetime date, variant format)}
   239 The format specification is described at \l{QML:Qt::formatDateTime}{Qt.formatDateTime}.
   241 The format specification is described at \l{QML:Qt::formatDateTime}{Qt.formatDateTime}.
   240 
   242 
   241 
   243 
   242 \section1 Dynamic Object Creation
   244 \section1 Dynamic Object Creation
   243 The following functions on the global object allow you to dynamically create QML
   245 The following functions on the global object allow you to dynamically create QML
   244 items from files or strings. See \l{Dynamic Object Management} for an overview
   246 items from files or strings. See \l{Dynamic Object Management in QML} for an overview
   245 of their use.
   247 of their use.
   246 
   248 
   247 \list
   249 \list
   248     \o \l{QML:Qt::createComponent()}{object Qt.createComponent(url)}
   250     \o \l{QML:Qt::createComponent()}{object Qt.createComponent(url)}
   249     \o \l{QML:Qt::createQmlObject()}{object Qt.createQmlObject(string qml, object parent, string filepath)}
   251     \o \l{QML:Qt::createQmlObject()}{object Qt.createQmlObject(string qml, object parent, string filepath)}
   255 : captureProperties(false), rootContext(0), isDebugging(false),
   257 : captureProperties(false), rootContext(0), isDebugging(false),
   256   outputWarningsToStdErr(true), contextClass(0), sharedContext(0), sharedScope(0),
   258   outputWarningsToStdErr(true), contextClass(0), sharedContext(0), sharedScope(0),
   257   objectClass(0), valueTypeClass(0), globalClass(0), cleanup(0), erroredBindings(0),
   259   objectClass(0), valueTypeClass(0), globalClass(0), cleanup(0), erroredBindings(0),
   258   inProgressCreations(0), scriptEngine(this), workerScriptEngine(0), componentAttached(0),
   260   inProgressCreations(0), scriptEngine(this), workerScriptEngine(0), componentAttached(0),
   259   inBeginCreate(false), networkAccessManager(0), networkAccessManagerFactory(0),
   261   inBeginCreate(false), networkAccessManager(0), networkAccessManagerFactory(0),
   260   typeManager(e), importDatabase(e), uniqueId(1)
   262   typeLoader(e), importDatabase(e), uniqueId(1)
   261 {
   263 {
   262     if (!qt_QmlQtModule_registered) {
   264     if (!qt_QmlQtModule_registered) {
   263         qt_QmlQtModule_registered = true;
   265         qt_QmlQtModule_registered = true;
   264         QDeclarativeItemModule::defineModule();
   266         QDeclarativeItemModule::defineModule();
   265         QDeclarativeUtilModule::defineModule();
   267         QDeclarativeUtilModule::defineModule();
   299     offlineStoragePath = QDesktopServices::storageLocation(QDesktopServices::DataLocation).replace(QLatin1Char('/'), QDir::separator())
   301     offlineStoragePath = QDesktopServices::storageLocation(QDesktopServices::DataLocation).replace(QLatin1Char('/'), QDir::separator())
   300         + QDir::separator() + QLatin1String("QML")
   302         + QDir::separator() + QLatin1String("QML")
   301         + QDir::separator() + QLatin1String("OfflineStorage");
   303         + QDir::separator() + QLatin1String("OfflineStorage");
   302 #endif
   304 #endif
   303 
   305 
       
   306 #ifndef QT_NO_XMLSTREAMREADER
   304     qt_add_qmlxmlhttprequest(this);
   307     qt_add_qmlxmlhttprequest(this);
       
   308 #endif
   305     qt_add_qmlsqldatabase(this);
   309     qt_add_qmlsqldatabase(this);
   306     // XXX A Multimedia "Qt.Sound" class also needs to be made available,
   310     // XXX A Multimedia "Qt.Sound" class also needs to be made available,
   307     // XXX but we don't want a dependency in that cirection.
   311     // XXX but we don't want a dependency in that cirection.
   308     // XXX When the above a done some better way, that way should also be
   312     // XXX When the above a done some better way, that way should also be
   309     // XXX used to add Qt.Sound class.
   313     // XXX used to add Qt.Sound class.
   327         qtObject.setProperty(QLatin1String("lighter"), newFunction(QDeclarativeEnginePrivate::lighter, 1));
   331         qtObject.setProperty(QLatin1String("lighter"), newFunction(QDeclarativeEnginePrivate::lighter, 1));
   328         qtObject.setProperty(QLatin1String("darker"), newFunction(QDeclarativeEnginePrivate::darker, 1));
   332         qtObject.setProperty(QLatin1String("darker"), newFunction(QDeclarativeEnginePrivate::darker, 1));
   329         qtObject.setProperty(QLatin1String("tint"), newFunction(QDeclarativeEnginePrivate::tint, 2));
   333         qtObject.setProperty(QLatin1String("tint"), newFunction(QDeclarativeEnginePrivate::tint, 2));
   330     }
   334     }
   331 
   335 
   332 #ifndef QT_NO_TEXTDATE
   336 #ifndef QT_NO_DATESTRING
   333     //date/time formatting
   337     //date/time formatting
   334     qtObject.setProperty(QLatin1String("formatDate"),newFunction(QDeclarativeEnginePrivate::formatDate, 2));
   338     qtObject.setProperty(QLatin1String("formatDate"),newFunction(QDeclarativeEnginePrivate::formatDate, 2));
   335     qtObject.setProperty(QLatin1String("formatTime"),newFunction(QDeclarativeEnginePrivate::formatTime, 2));
   339     qtObject.setProperty(QLatin1String("formatTime"),newFunction(QDeclarativeEnginePrivate::formatTime, 2));
   336     qtObject.setProperty(QLatin1String("formatDateTime"),newFunction(QDeclarativeEnginePrivate::formatDateTime, 2));
   340     qtObject.setProperty(QLatin1String("formatDateTime"),newFunction(QDeclarativeEnginePrivate::formatDateTime, 2));
   337 #endif
   341 #endif
   432             ps->d = 0;
   436             ps->d = 0;
   433     }
   437     }
   434     pss.clear();
   438     pss.clear();
   435 }
   439 }
   436 
   440 
   437 Q_GLOBAL_STATIC(QDeclarativeEngineDebugServer, qmlEngineDebugServer);
       
   438 
       
   439 void QDeclarativePrivate::qdeclarativeelement_destructor(QObject *o)
   441 void QDeclarativePrivate::qdeclarativeelement_destructor(QObject *o)
   440 {
   442 {
   441     QObjectPrivate *p = QObjectPrivate::get(o);
   443     QObjectPrivate *p = QObjectPrivate::get(o);
   442     if (p->declarativeData) {
   444     if (p->declarativeData) {
   443         QDeclarativeData *d = static_cast<QDeclarativeData*>(p->declarativeData);
   445         QDeclarativeData *d = static_cast<QDeclarativeData*>(p->declarativeData);
   475     listClass = new QDeclarativeListScriptClass(q);
   477     listClass = new QDeclarativeListScriptClass(q);
   476     rootContext = new QDeclarativeContext(q,true);
   478     rootContext = new QDeclarativeContext(q,true);
   477 
   479 
   478     if (QCoreApplication::instance()->thread() == q->thread() &&
   480     if (QCoreApplication::instance()->thread() == q->thread() &&
   479         QDeclarativeEngineDebugServer::isDebuggingEnabled()) {
   481         QDeclarativeEngineDebugServer::isDebuggingEnabled()) {
   480         qmlEngineDebugServer();
       
   481         isDebugging = true;
   482         isDebugging = true;
   482         QDeclarativeEngineDebugServer::addEngine(q);
   483         QDeclarativeEngineDebugServer::instance()->addEngine(q);
   483     }
   484     }
   484 }
   485 }
   485 
   486 
   486 QDeclarativeWorkerScriptEngine *QDeclarativeEnginePrivate::getWorkerScriptEngine()
   487 QDeclarativeWorkerScriptEngine *QDeclarativeEnginePrivate::getWorkerScriptEngine()
   487 {
   488 {
   541 */
   542 */
   542 QDeclarativeEngine::~QDeclarativeEngine()
   543 QDeclarativeEngine::~QDeclarativeEngine()
   543 {
   544 {
   544     Q_D(QDeclarativeEngine);
   545     Q_D(QDeclarativeEngine);
   545     if (d->isDebugging)
   546     if (d->isDebugging)
   546         QDeclarativeEngineDebugServer::remEngine(this);
   547         QDeclarativeEngineDebugServer::instance()->remEngine(this);
   547 }
   548 }
   548 
   549 
   549 /*! \fn void QDeclarativeEngine::quit()
   550 /*! \fn void QDeclarativeEngine::quit()
   550     This signal is emitted when the QDeclarativeEngine quits.
   551     This signal is emitted when the QML loaded by the engine would like to quit.
   551  */
   552  */
   552 
   553 
   553 /*! \fn void QDeclarativeEngine::warnings(const QList<QDeclarativeError> &warnings)
   554 /*! \fn void QDeclarativeEngine::warnings(const QList<QDeclarativeError> &warnings)
   554     This signal is emitted when \a warnings messages are generated by QML.
   555     This signal is emitted when \a warnings messages are generated by QML.
   555  */
   556  */
   562   reloaded.
   563   reloaded.
   563  */
   564  */
   564 void QDeclarativeEngine::clearComponentCache()
   565 void QDeclarativeEngine::clearComponentCache()
   565 {
   566 {
   566     Q_D(QDeclarativeEngine);
   567     Q_D(QDeclarativeEngine);
   567     d->typeManager.clearCache();
   568     d->typeLoader.clearCache();
   568 }
   569 }
   569 
   570 
   570 /*!
   571 /*!
   571   Returns the engine's root context.
   572   Returns the engine's root context.
   572 
   573 
   668 */
   669 */
   669 void QDeclarativeEngine::addImageProvider(const QString &providerId, QDeclarativeImageProvider *provider)
   670 void QDeclarativeEngine::addImageProvider(const QString &providerId, QDeclarativeImageProvider *provider)
   670 {
   671 {
   671     Q_D(QDeclarativeEngine);
   672     Q_D(QDeclarativeEngine);
   672     QMutexLocker locker(&d->mutex);
   673     QMutexLocker locker(&d->mutex);
   673     d->imageProviders.insert(providerId, provider);
   674     d->imageProviders.insert(providerId, QSharedPointer<QDeclarativeImageProvider>(provider));
   674 }
   675 }
   675 
   676 
   676 /*!
   677 /*!
   677   Returns the QDeclarativeImageProvider set for \a providerId.
   678   Returns the QDeclarativeImageProvider set for \a providerId.
   678 */
   679 */
   679 QDeclarativeImageProvider *QDeclarativeEngine::imageProvider(const QString &providerId) const
   680 QDeclarativeImageProvider *QDeclarativeEngine::imageProvider(const QString &providerId) const
   680 {
   681 {
   681     Q_D(const QDeclarativeEngine);
   682     Q_D(const QDeclarativeEngine);
   682     QMutexLocker locker(&d->mutex);
   683     QMutexLocker locker(&d->mutex);
   683     return d->imageProviders.value(providerId);
   684     return d->imageProviders.value(providerId).data();
   684 }
   685 }
   685 
   686 
   686 /*!
   687 /*!
   687   Removes the QDeclarativeImageProvider for \a providerId.
   688   Removes the QDeclarativeImageProvider for \a providerId.
   688 
   689 
   692 */
   693 */
   693 void QDeclarativeEngine::removeImageProvider(const QString &providerId)
   694 void QDeclarativeEngine::removeImageProvider(const QString &providerId)
   694 {
   695 {
   695     Q_D(QDeclarativeEngine);
   696     Q_D(QDeclarativeEngine);
   696     QMutexLocker locker(&d->mutex);
   697     QMutexLocker locker(&d->mutex);
   697     delete d->imageProviders.take(providerId);
   698     d->imageProviders.take(providerId);
   698 }
   699 }
   699 
   700 
   700 QDeclarativeImageProvider::ImageType QDeclarativeEnginePrivate::getImageProviderType(const QUrl &url)
   701 QDeclarativeImageProvider::ImageType QDeclarativeEnginePrivate::getImageProviderType(const QUrl &url)
   701 {
   702 {
   702     QMutexLocker locker(&mutex);
   703     QMutexLocker locker(&mutex);
   703     QDeclarativeImageProvider *provider = imageProviders.value(url.host());
   704     QSharedPointer<QDeclarativeImageProvider> provider = imageProviders.value(url.host());
       
   705     locker.unlock();
   704     if (provider)
   706     if (provider)
   705         return provider->imageType();
   707         return provider->imageType();
   706     return static_cast<QDeclarativeImageProvider::ImageType>(-1);
   708     return static_cast<QDeclarativeImageProvider::ImageType>(-1);
   707 }
   709 }
   708 
   710 
   709 QImage QDeclarativeEnginePrivate::getImageFromProvider(const QUrl &url, QSize *size, const QSize& req_size)
   711 QImage QDeclarativeEnginePrivate::getImageFromProvider(const QUrl &url, QSize *size, const QSize& req_size)
   710 {
   712 {
   711     QMutexLocker locker(&mutex);
   713     QMutexLocker locker(&mutex);
   712     QImage image;
   714     QImage image;
   713     QDeclarativeImageProvider *provider = imageProviders.value(url.host());
   715     QSharedPointer<QDeclarativeImageProvider> provider = imageProviders.value(url.host());
       
   716     locker.unlock();
   714     if (provider)
   717     if (provider)
   715         image = provider->requestImage(url.path().mid(1), size, req_size);
   718         image = provider->requestImage(url.path().mid(1), size, req_size);
   716     return image;
   719     return image;
   717 }
   720 }
   718 
   721 
   719 QPixmap QDeclarativeEnginePrivate::getPixmapFromProvider(const QUrl &url, QSize *size, const QSize& req_size)
   722 QPixmap QDeclarativeEnginePrivate::getPixmapFromProvider(const QUrl &url, QSize *size, const QSize& req_size)
   720 {
   723 {
   721     QMutexLocker locker(&mutex);
   724     QMutexLocker locker(&mutex);
   722     QPixmap pixmap;
   725     QPixmap pixmap;
   723     QDeclarativeImageProvider *provider = imageProviders.value(url.host());
   726     QSharedPointer<QDeclarativeImageProvider> provider = imageProviders.value(url.host());
       
   727     locker.unlock();
   724     if (provider)
   728     if (provider)
   725         pixmap = provider->requestPixmap(url.path().mid(1), size, req_size);
   729         pixmap = provider->requestPixmap(url.path().mid(1), size, req_size);
   726     return pixmap;
   730     return pixmap;
   727 }
   731 }
   728 
   732 
  1102 
  1106 
  1103 /*!
  1107 /*!
  1104 \qmlmethod object Qt::createComponent(url)
  1108 \qmlmethod object Qt::createComponent(url)
  1105 
  1109 
  1106 Returns a \l Component object created using the QML file at the specified \a url,
  1110 Returns a \l Component object created using the QML file at the specified \a url,
  1107 or \c null if there was an error in creating the component.
  1111 or \c null if an empty string was given.
       
  1112 
       
  1113 The returned component's \l Component::status property indicates whether the
       
  1114 component was successfully created. If the status is \c Component.Error, 
       
  1115 see \l Component::errorString() for an error description.
  1108 
  1116 
  1109 Call \l {Component::createObject()}{Component.createObject()} on the returned
  1117 Call \l {Component::createObject()}{Component.createObject()} on the returned
  1110 component to create an object instance of the component.
  1118 component to create an object instance of the component.
  1111 
  1119 
  1112 Here is an example. Notice it checks whether the component \l{Component::status}{status} is
  1120 For example:
  1113 \c Component.Ready before calling \l {Component::createObject()}{createObject()}
  1121 
  1114 in case the QML file is loaded over a network and thus is not ready immediately.
  1122 \snippet doc/src/snippets/declarative/createComponent-simple.qml 0
  1115 
  1123 
  1116 \snippet doc/src/snippets/declarative/componentCreation.js vars
  1124 See \l {Dynamic Object Management in QML} for more information on using this function.
  1117 \codeline
       
  1118 \snippet doc/src/snippets/declarative/componentCreation.js func
       
  1119 \snippet doc/src/snippets/declarative/componentCreation.js remote
       
  1120 \snippet doc/src/snippets/declarative/componentCreation.js func-end
       
  1121 \codeline
       
  1122 \snippet doc/src/snippets/declarative/componentCreation.js finishCreation
       
  1123 
       
  1124 If you are certain the QML file to be loaded is a local file, you could omit the \c finishCreation() 
       
  1125 function and call \l {Component::createObject()}{createObject()} immediately:
       
  1126 
       
  1127 \snippet doc/src/snippets/declarative/componentCreation.js func
       
  1128 \snippet doc/src/snippets/declarative/componentCreation.js local
       
  1129 \snippet doc/src/snippets/declarative/componentCreation.js func-end
       
  1130 
  1125 
  1131 To create a QML object from an arbitrary string of QML (instead of a file),
  1126 To create a QML object from an arbitrary string of QML (instead of a file),
  1132 use \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()}.
  1127 use \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()}.
  1133 */
  1128 */
  1134 
  1129 
  1175 Each object in this array has the members \c lineNumber, \c columnNumber, \c fileName and \c message.
  1170 Each object in this array has the members \c lineNumber, \c columnNumber, \c fileName and \c message.
  1176 
  1171 
  1177 Note that this function returns immediately, and therefore may not work if
  1172 Note that this function returns immediately, and therefore may not work if
  1178 the \a qml string loads new components (that is, external QML files that have not yet been loaded).
  1173 the \a qml string loads new components (that is, external QML files that have not yet been loaded).
  1179 If this is the case, consider using \l{QML:Qt::createComponent()}{Qt.createComponent()} instead.
  1174 If this is the case, consider using \l{QML:Qt::createComponent()}{Qt.createComponent()} instead.
       
  1175 
       
  1176 See \l {Dynamic Object Management in QML} for more information on using this function.
  1180 */
  1177 */
  1181 
  1178 
  1182 QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngine *engine)
  1179 QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngine *engine)
  1183 {
  1180 {
  1184     QDeclarativeEnginePrivate *activeEnginePriv =
  1181     QDeclarativeEnginePrivate *activeEnginePriv =
  1299 
  1296 
  1300 /*!
  1297 /*!
  1301 \qmlmethod string Qt::formatDate(datetime date, variant format)
  1298 \qmlmethod string Qt::formatDate(datetime date, variant format)
  1302 Returns the string representation of \c date, formatted according to \c format.
  1299 Returns the string representation of \c date, formatted according to \c format.
  1303 */
  1300 */
  1304 #ifndef QT_NO_TEXTDATE
  1301 #ifndef QT_NO_DATESTRING
  1305 QScriptValue QDeclarativeEnginePrivate::formatDate(QScriptContext*ctxt, QScriptEngine*engine)
  1302 QScriptValue QDeclarativeEnginePrivate::formatDate(QScriptContext*ctxt, QScriptEngine*engine)
  1306 {
  1303 {
  1307     int argCount = ctxt->argumentCount();
  1304     int argCount = ctxt->argumentCount();
  1308     if(argCount == 0 || argCount > 2)
  1305     if(argCount == 0 || argCount > 2)
  1309         return ctxt->throwError(QLatin1String("Qt.formatDate(): Invalid arguments"));
  1306         return ctxt->throwError(QLatin1String("Qt.formatDate(): Invalid arguments"));
  1440             return ctxt->throwError(QLatin1String("Qt.formatDateTime(): Invalid datetime format"));
  1437             return ctxt->throwError(QLatin1String("Qt.formatDateTime(): Invalid datetime format"));
  1441         }
  1438         }
  1442     }
  1439     }
  1443     return engine->newVariant(qVariantFromValue(date.toString(enumFormat)));
  1440     return engine->newVariant(qVariantFromValue(date.toString(enumFormat)));
  1444 }
  1441 }
  1445 #endif // QT_NO_TEXTDATE
  1442 #endif // QT_NO_DATESTRING
  1446 
  1443 
  1447 /*!
  1444 /*!
  1448 \qmlmethod color Qt::rgba(real red, real green, real blue, real alpha)
  1445 \qmlmethod color Qt::rgba(real red, real green, real blue, real alpha)
  1449 
  1446 
  1450 Returns a color with the specified \c red, \c green, \c blue and \c alpha components.
  1447 Returns a color with the specified \c red, \c green, \c blue and \c alpha components.
  1717 
  1714 
  1718 void QDeclarativeEnginePrivate::sendQuit()
  1715 void QDeclarativeEnginePrivate::sendQuit()
  1719 {
  1716 {
  1720     Q_Q(QDeclarativeEngine);
  1717     Q_Q(QDeclarativeEngine);
  1721     emit q->quit();
  1718     emit q->quit();
       
  1719     if (q->receivers(SIGNAL(quit())) == 0) {
       
  1720         qWarning("Signal QDeclarativeEngine::quit() emitted, but no receivers connected to handle it.");
       
  1721     }
  1722 }
  1722 }
  1723 
  1723 
  1724 static void dumpwarning(const QDeclarativeError &error)
  1724 static void dumpwarning(const QDeclarativeError &error)
  1725 {
  1725 {
  1726     qWarning().nospace() << qPrintable(error.toString());
  1726     qWarning().nospace() << qPrintable(error.toString());
  2077 void QDeclarativeEnginePrivate::registerCompositeType(QDeclarativeCompiledData *data)
  2077 void QDeclarativeEnginePrivate::registerCompositeType(QDeclarativeCompiledData *data)
  2078 {
  2078 {
  2079     QByteArray name = data->root->className();
  2079     QByteArray name = data->root->className();
  2080 
  2080 
  2081     QByteArray ptr = name + '*';
  2081     QByteArray ptr = name + '*';
  2082     QByteArray lst = "QDeclarativeListProperty<" + name + ">";
  2082     QByteArray lst = "QDeclarativeListProperty<" + name + '>';
  2083 
  2083 
  2084     int ptr_type = QMetaType::registerType(ptr.constData(), voidptr_destructor,
  2084     int ptr_type = QMetaType::registerType(ptr.constData(), voidptr_destructor,
  2085                                            voidptr_constructor);
  2085                                            voidptr_constructor);
  2086     int lst_type = QMetaType::registerType(lst.constData(), voidptr_destructor,
  2086     int lst_type = QMetaType::registerType(lst.constData(), voidptr_destructor,
  2087                                            voidptr_constructor);
  2087                                            voidptr_constructor);
  2111 }
  2111 }
  2112 
  2112 
  2113 QObject *QDeclarativeEnginePrivate::toQObject(const QVariant &v, bool *ok) const
  2113 QObject *QDeclarativeEnginePrivate::toQObject(const QVariant &v, bool *ok) const
  2114 {
  2114 {
  2115     int t = v.userType();
  2115     int t = v.userType();
  2116     if (m_compositeTypes.contains(t)) {
  2116     if (t == QMetaType::QObjectStar || m_compositeTypes.contains(t)) {
  2117         if (ok) *ok = true;
  2117         if (ok) *ok = true;
  2118         return *(QObject **)(v.constData());
  2118         return *(QObject **)(v.constData());
  2119     } else {
  2119     } else {
  2120         return QDeclarativeMetaType::toQObject(v, ok);
  2120         return QDeclarativeMetaType::toQObject(v, ok);
  2121     }
  2121     }