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

Asynchronous Loader is not asynchronous when using QQuickWindow derived class

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.2.0, 5.3.2, 5.4.0
    • None
    • Linux Fedora 20, Windows 8.1

    Description

      When I have a simple project containing QML Window element and asynchronous Loader everything is good.
      However, at some point, I decided that I need to extend the Window functionalities (eg. by adding additional invokable method), so I have created MyWindow class derived from QQuickWindow.
      Unexpectedly, when I replaced Window with MyWindow in qml, all asynchronous Loader started behaving as if they were synchronous.
      I found that intriguing – why deriving a custom Window class from QQuickWindow breaks the old Window-provided functionalities?

      Here are some of my investigations – all cases were tested against Loader with asynchronous set to true and checking if asynchronous is really working (see qml file used for testing as attachement):

      1. Creating Window using "import QtQuick.Window 2.1" or 2.2 – Loaders are asynchronous as expected
      2. Creating Window using "import QtQuick.Window 2.0"-- Loaders are NOT asynchronous
      3. Creating Custom Window using "import QtQuick.Window 2.1" or 2.2 – Loaders are NOT asynchronous

      as for 3.) creating Window (Qml item) from component makes Loaders to start to act like expected: comp.createObject(rootWindow, {}) when comp is Component {id: comp Window {}}

      I investigated it even further and found out that a QML Window element actually does not instantiate the QQuickWindow (as documentation states) but some internal QQuickWindowQmlImpl class that in its classBegin() method sets incubation controller on the engine.
      Since a user-defined custom window is not inheriting QQuickWindowQmlImpl (and it cannot inherit it, as the class in not defined in any visible header), user wanting to customize Window behavior inadvertently loses all the goodies that class provides.

      I find such behavior surprising and bad design. It is possible to work around the problem by copying parts of QQuickWindowQmlImpl code into the user-defined custom window class but I don't think it is a right thing to do.

      It should be documented exactly which class QML Window type instantiates and such class should be accessible to the user.

      Attachments

        1. main.cpp
          0.5 kB
        2. main.qml
          1 kB
        3. mywindow.cpp
          0.6 kB
        4. mywindow.h
          0.3 kB
        5. qtbug44379.zip
          3 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            aalpert Alan Alpert
            pawelp Paweł Pietraszko
            Votes:
            6 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes