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

Invoking Help on pointer variable fails with ClangCodeModel

    XMLWordPrintable

Details

    • Linux/X11, Windows
    • 6889f4df80d21b2121eef85cac2a6f58dd946106 (qt-creator/qt-creator/4.8)

    Description

      Consider the following silly (but functioning) example:

      #include <QtCore/QString>
      
      #include <iostream>
      #include <memory>
      
      int main(int argc, char const *argv[]) {
        QString *strPtr = new QString("hello ");
        QString str("world");
        auto smartStrPtr = std::make_unique<QString>("\n");
      
        std::cout << strPtr->toStdString() << str.toStdString()
                  << smartStrPtr->toStdString();
      
        delete strPtr;
      
        return 0;
      }
      
      

      If the Clang Code Model plugin is enabled, pressing F1 on strPtr or smartStrPtr yields "No documentation available." Pressing F1 on str or any of the occurences of QString opens the help for the QString class. With the Clang Code Model plugin disabled pressing F1 on both strPtr and smartStrPtr works just fine.

      This example is contrived, but pressing F1 on e.g. ui->someWidget is very useful if the widget is not well know to you. And there may not be an occurrence of the type in the next nearby:

      Dialog::Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog) {
        ui->setupUi(this);
        ui->label->setText("hello");
      }
      

      Pressing F1 on label does not provide the help for the QLabel class. But interestingly, I just found out that pressing F1 on setText takes me straight to the help for QLabel's "text" property. I can probably use this trick.

      Following these instructions I got the following diagnostics for the last two cases mentioned:

      [2908] qtc.clangcodemodel.ipc: >>> RequestToolTipMessage(FileContainer(C:/Users/osse/dev/stats/dialog.cpp, Utf8StringVector(), Utf8StringVector(), 1, UTF-8), 1, 9, 10, )
      [2908] qtc.clangcodemodel.hover: Requesting tooltip info at 155
      [2908] qtc.clangcodemodel.ipc: <==== ToolTipMessage QLabel *
      [2908] qtc.clangcodemodel.hover: Processing tooltip info "QLabel *"
      [2908] qtc.clangcodemodel.hover: Querying help manager with "Ui_Dialog::label" "" Unknown
      [2908] qtc.clangcodemodel.hover: Querying help manager with "label" "" Unknown
      [2908] QTextBrowser: No document for about:blank
      [2908] qtc.clangcodemodel.ipc: ====> DocumentVisibilityChangedMessage(, )
      
      [2908] qtc.clangcodemodel.ipc: ====> DocumentVisibilityChangedMessage(C:/Users/osse/dev/stats/dialog.cpp, C:/Users/osse/dev/stats/dialog.cpp, )
      [2908] qtc.clangcodemodel.ipc: ====> RequestReferencesMessage(FileContainer(C:/Users/osse/dev/stats/dialog.cpp, Utf8StringVector(), Utf8StringVector(), 1, ), 2, 9, 16, false, )
      [2908] qtc.clangcodemodel.ipc: <==== ReferencesMessage with 1 references
      [2908] qtc.clangcodemodel.ipc: >>> RequestToolTipMessage(FileContainer(C:/Users/osse/dev/stats/dialog.cpp, Utf8StringVector(), Utf8StringVector(), 1, UTF-8), 2, 9, 17, )
      [2908] qtc.clangcodemodel.hover: Requesting tooltip info at 162
      [2908] qtc.clangcodemodel.ipc: <==== ToolTipMessage void QLabel::setText(const QString &)
      [2908] qtc.clangcodemodel.hover: Processing tooltip info "void QLabel::setText(const QString &)"
      [2908] qtc.clangcodemodel.hover: Querying help manager with "QLabel::setText" "setText(const QString &)" Function
      [2908] qtc.clangcodemodel.hover:   Match!
      [2908] qtc.clangcodemodel.ipc: ====> DocumentVisibilityChangedMessage(, )
      

      Attachments

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

        Activity

          People

            kosjar Nikolai Kosjar
            ow Øystein Walle
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes