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

Clang: Broken handling of *.ui files and corresponding ui_*.h headers

    XMLWordPrintable

Details

    • d52ac9a7084df220a5349468703c11cc1c0794c4 (qt-creator/qt-creator/4.8)

    Description

      Currently the handling of *.ui files is broken:

      1. Create a Qt Widget Application
      2. Diagnostics are emitted in mainwindow.cpp regarding the UI::MainWindow object (e.g. error: allocation of incomplete type 'Ui::MainWindow')
      3. Updates of the *.ui files are not reflected in the completion items

      There is a race condition between registering the unsaved file ui_mainwindow.h and the first parsing of the translation unit.

      If the unsaved file is registered first, the described issue will not appear.
      If the unsaved file is registered after the first parsing, further updates to the unsaved files are not reflected properly.

      The registration of the unsaved file depends on the UiCodeModelSupport - when the process is finished, the contents will be propagated to the clang plugin which will notify the backend. This process is usually finished after CppModelManager::updateProjectInfo() is called. This is the case since the qmake project manager works asynchronously. Same applies for the qbs project manager.

      The registration of the file depends mainly on the calculation of the project part - as soon as this is determined, the backend is requested to register the translation unit.

      Two important points:

      • The order is only relevant if the translation is parsed with the CXTranslationUnit_CacheCompletionResults and the CXTranslationUnit_PrecompiledPreamble option (leave one out and it works). We need both options.
      • Furthermore, if ui_mainwindow.h does actually exist on the file system, no issue occurs. Note that the clang documentation for CXUnsavedFile clearly states, that the file must exist in the file system.

      Since the project manager will probably stay asynchronous, we either have to change libclang or create the file in the file system - the latter might have side effects for the build system.

      Attachments

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

        Activity

          People

            kosjar Nikolai Kosjar
            kosjar Nikolai Kosjar
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes