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

Conflicts between multiple similar opened but separate CMake projects in current session

    XMLWordPrintable

Details

    Description

      It seems that Qt Creator looks into all files with the same name and code structure (as in same class name and method inside) when it comes to declaration of a class function no matter if that declaration belongs to the currently active project or not. When going to the declaration of a class function (let's call it `A::func()`) which is yet to be implemented inside the sources for that class in a given project, if another file with the same name, class and function (which is implemented!) is part of a project in the same session Qt Creator goes to that file and line in the code. The issue occurs regardless of the filestructure (as in which folder the files are located in) as long as the files that are concerned are part of the respective pair of `cmake` projects.

      Here is a detailed video on YouTube where I demonstrate the issue: https://www.youtube.com/watch?v=TQHCSG8o9r8

      Sorry for posting it in such a format but it's hard for me to describe it otherwise.

      *UPDATE:*

      The previously reported issue much deeper than I thought. In one project of mine I am including the path to the headers of and also linking against `OpenCV` inside the `CMakeLists.txt` of that project as well as using those headers in my own code by including them. In another projects opened in the same session I currently have no `OpenCV`-related functionality and even in the `CMakeLists.txt` there is not a hint that points at that library. However I just discovered that the conflict between the first and second project goes beyond trivial similarity in names of files and classes as previously described at the beginning of this post. Below you can read what I did and what I found out.

      I've just created a class called `node` using the file wizard. The way the wizard works in this case is to create both the header and source file for the given class plus an empty implementation of the default constructor. Since I actually wanted to write `Node` (capital `N`, naming conventions and all that...) I decided to use refactoring (fastest way to rename stuff when having to deal with a symbol present in multiple files). Before I describe what the results of attempting to do that was, I have to point out (again) that the second project (where I created the `node` class) has NO connection to `OpenCV` of any kind - `CMakeLists.txt`, included headers from that library in my own headers and source files or any other way of adding the library to my project. The previous version of the project DOES have it all though - include path added to project, linking against the library, using its header files etc. Now if we go back to the refactoring once I hit the hotkey to trigger it I got a very, very unexpected result namely I had three instead of two files where that symbol was found:

      • *node.h* - created by me through the file wizard this is an expected result
      • *node.cpp* - same as *node.h*
      • */usr/local/include/opencv2/core/core_c.h* - 9 occurrences in total in a file that is not part of the project at all

      It is true that you can deselect that third file by unchecking the checkbox at the beginning of the entry that is part of the list of found occurrences however this is far from an intuitive and omho expected behaviour. Just like with previous state of this issue I closed the first project thus removing it from the session and refactoring worked just fine. Unlike the issue with same file, class name and function name in this case I have two very different names:

      • *first project* - links against `OpenCV` and has files *blah_node.h* and *blah_node.cpp* with the `BlahNode` class inside
      • *second project* - doesn't use `OpenCV` and has files *node.h* and *node.cpp* with the `node` class inside

      Attachments

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

        Activity

          People

            rbaleksandar Red Baron
            rbaleksandar Red Baron
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes