Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-25240

qmljs: Race condition in dependency loading

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • None
    • Qt Creator 4.13.0, Qt Creator 4.14.0
    • Quick / QML Support

    Description

      QmlJS::Link::loadPlugintypes which can be invoked during linking looks like this

      // move to the owning thread
      metaObject()->invokeMethod(this, [=]

      { onLoadPluginTypes(libraryPath, importPath, importUri, importVersion); }

      );

      It will subsequently crate a future and one can check when all futures in the model manager are processed to know that everything is loaded.
      The issue comes when invokeMethod is delayed, and then one will not know about the future and will not have loaded everything.
      What is worse simply waiting for all futures is never able to guarantee a full load.
      In the tests manually running the event loop seems to fix it, but I guess that is at the center of many subtle issues QML Designer Studio has, and things like double linking hacks.
      I guess the clean way is to either explicitly use a thread, and a queue for the code model, or at least detect it using an atomic counter or mutex protected state that is set increased before the invoke, and decreased in it.

      I plan to go with atomic counter + registrable callbacks called at the end of the load (a bit like in the dom model).

      Attachments

        Activity

          People

            fawzi Fawzi Mohamed
            fawzi Fawzi Mohamed
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: