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

Re-registration of singleton types doesn't work

    XMLWordPrintable

Details

    • 2cfe1bb09c11432ca5033f9589243e9e62fe9488

    Description

      If I do the following

      cpp:
      qmlRegisterType<MyType1>("MyModule", 1, 0, "MyType");
      qmlRegisterType<MyType2>("MyModule", 1, 0, "MyType");
      runSomeQmlApplication();
      
      qml:
      MyType{ ... }
      

      then QML will instantiate MyType2. This makes sense, it was the last type to be registered.

      However, if I do this

      cpp:
      qmlRegisterSingletonType<MySingleton1>("MyModule", 1, 0, "MySingleton", createMySingleton1);
      qmlRegisterSingletonType<MySingleton2>("MyModule", 1, 0, "MySingleton", createMySingleton2);
      
      qml:
      MySingleton.callSomeMethod();
      

      then QML will call MySingleton1::callSomeMethod.

      This is not only inconsistent, it's blocking a work-aoround for QTBUG-56172. Related to QTBUG-56532.

      Attachments

        1. QTBUG-56521.zip
          5 kB
        2. QTBUG-56521.zip
          2 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            andysh Andy Shaw
            jornb Jørn Bersvendsen
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes