Bug 312576

Summary: generates incorrect includes for QObject subclass
Product: [Developer tools] kdevplatform Reporter: Andreas Pakulat <apaku>
Component: templatesAssignee: kdevelop-bugs-null
Status: RESOLVED FIXED    
Severity: major    
Priority: NOR    
Version: git master   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Qt3 CMake project to reproduce the Qt3 problem

Description Andreas Pakulat 2013-01-04 00:17:16 UTC
When creating a QObject subclass template in some cases the generated include for the QObject header is not <QObject>, <QtCore/QObject> or <qobject.h> (for qt3) but rather something like <qt4/QtCore/QObject> or even <../../home/myname/qt-x11-free-3.3.8/src/kernel/qobject.h> (for qt3). This is of course wrong and won't even compile with the standard CMake project setup.

With Qt4/CMake projects this only seems to happen when generating files inside a subfolder instead of the project root dir.

The Qt3 case may hint that the "QObject" header is handled somehow specially or so, i.e. there's some code which tries to determine the <QtCore/QObject> part from the actual qobject.h file where the class is declared. This of course fails for Qt3. If Qt3 is supposed to be supported, that case needs to generate just <qobject.h>

Reproducible: Always

Steps to Reproduce:
1. Generate a new Qt Terminal project
2. Create a subfolder called 'foo'
3. Create a QObject subclass file template
4. Skip through all the pages, leaving everything at the default

For Qt3 I'm attaching a pre-setup project, simply set CMAKE_PREFIX_PATH to a Qt3 installation directory when opening the project in KDevelop. The steps are the same as above, except the extra subdir creation can be skipped.
Actual Results:  
#include <qt4/QtCore/QObject> is generated on a Debian system with the 'Qt dir' in /usr/share/qt4.

For Qt3 its #include <../../home/myname/qt-x11-free-3.3.8/src/kernel/qobject.h> for a Qt3 install in /home/myname/qt-x11-free-3.3.8.

Expected Results:  
#include <QtCore/QObject> is generated.
Comment 1 Andreas Pakulat 2013-01-04 00:17:51 UTC
Created attachment 76173 [details]
Qt3 CMake project to reproduce the Qt3 problem
Comment 2 Milian Wolff 2015-11-14 20:13:14 UTC
Hello!

We are working on a new clang-based C/C++ language plugin for KDevelop 5 which
supersedes the old C++ plugin in KDevelop 4. See e.g.:
https://www.kdevelop.org/news/first-beta-release-kdevelop-500-available

Due to a lack of manpower, we cannot fix bugs in the old C++ plugin. We rather
want to supply a good Clang based C++ experience for KDevelop 5 than wasting
our time on the legacy C++ support for KDevelop 4.

With the new clang-based C/C++ language plugin, the bug presented here does not occur. In my testing. For these reasons, I'll close this bug. Please stay tuned for KDevelop 5.

If you think this bug is applicable to Clang/KDevelop 5, please reopen the report and add new information on how to reproduce the bug there.

Sorry for the inconvenience, I hope you understand the reasoning above.

Cheers