Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-46040

Qml script Singleton for different QQmlEngine

    XMLWordPrintable

Details

    Description

      I have 2 thread each runnning their own QQmlEngine (the threads are not really important here, 2 QQmlEngine are). Instanciating their own Singleton from C++ with qmlRegisterSingletonType<T>() exposition with the callback with QQmlEngine *qml_engine make it possible to have a singleton instance per different engine. In Qml script (.qml) and qmldir singleton, the singleton get the same instance but the QQmlEngine complain that the singleton instance does not belong to the proper QQmlEngine.

      Even the qmlRegisterSingletonType with QUrl does not have a callback to give the proper instance per engine. Seem like only the first QQmlEngine that used a singleton can used it from that point on.

      If a singleton instance must belong to QQmlEngine to be usable, why not create one per QQmlEngine by default. Or at least make it possible to create one per QQmlEngine that request it.

      This observed into Qt 5.3.1, but since the API haven't changed I suspect it would still be there in 5.5.x.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            ulherman Ulf Hermann
            jeromegodbout Jerome Godbout
            Votes:
            4 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes