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

qmlpreview service not working with Qt Creator/Qt Design Studio

    XMLWordPrintable

Details

    • Linux/X11, macOS
    • 8482e2405 (10.0), c9a018adc (qds/4.1)

    Description

      The qmlpreview service not working with Qt Creator/Qt Design Studio is not working since Qt 6.4.3 anymore.

      We tested Qt 6.4.1, Qt 6.4.3 and Qt 6.5.1.

      With Qt 6.4.1 the service is still working.
      On Windows the immediate issue cannot be reprodced.

      The standalone tool qmlpreview does work.

      How to reproduce:

      • Create .qmlproject in Qt Creator or Qt Design Studio (4.1).
      • Configure a Qt kit with Qt 6.4.3 or Qt 6.5.x.
      • In Qt Design Studio by default we use qml2puppet as the runner. You can switch to the qml tool instead. For this bug this makes no difference.
      • Launch the live preview on a .qml file.

      Expected outcome:

      The live preview is launched.

      Bug:

      Instead of opening e.g. content/main.qml the URL is redirected to content/+en_US/+unix/+linux/+ubuntu/main.qml and the file cannot be opened and the preview fails.

      This issue seems to be triggered by the qmlpreview service, since using the standalone qmlpreview tool does work.

      We did some debugging on qmlpreviewconnectionmanager.cpp.

      connect(m_qmlPreviewClient.data(),
                  &QmlPreviewClient::pathRequested,
                  this,
                  [this](const QString &path) {
      
                      const bool found = m_projectFileFinder.findFileOrDirectory(
                          Utils::FilePath::fromString(path),
                          [&](const Utils::FilePath &filename, int confidence) {
                              if (m_fileLoader && confidence == path.length()) {
                                  bool success = false;
                                  QByteArray contents = m_fileLoader(filename.toFSPathString(), &success);
                                  if (success) {
                                      if (!m_fileSystemWatcher.watchesFile(filename)) {
                                          m_fileSystemWatcher
                                              .addFile(filename,
                                                       Utils::FileSystemWatcher::WatchModifiedDate);
                                      }
                                      m_qmlPreviewClient->announceFile(path, contents);
                                  } else {
                                      m_qmlPreviewClient->announceError(path);
                                  }
                              } else {
                                  m_qmlPreviewClient->announceError(path);
                              }
                          },
                          [&](const QStringList &entries, int confidence) {
                              if (confidence == path.length())
                                  m_qmlPreviewClient->announceDirectory(path, entries);
                              else
                                  m_qmlPreviewClient->announceError(path);
                          });
      
                      if (!found)
                          m_qmlPreviewClient->announceError(path);
                  });
      

      On Windows pathRequested() is not emitted for a single QML file and there are no file selectors in any path.

      As hotfix  always announcing an error seems to work at least in some cases.

      [&](const QStringList &entries, int confidence) {                     
                                  m_qmlPreviewClient->announceError(path);
                          });
      

      Attachments

        Issue Links

          For Gerrit Dashboard: QTCREATORBUG-29090
          # Subject Branch Project Status CR V

          Activity

            People

              ulherman Ulf Hermann
              thohartm Thomas Hartmann
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes