This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 132136 - code completion for C++ and Qt does not work under Windows
Summary: code completion for C++ and Qt does not work under Windows
Status: VERIFIED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Code Completion (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P1 blocker (vote)
Assignee: Vladimir Voskresensky
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-04-05 15:29 UTC by polzleitner
Modified: 2008-04-09 08:50 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
But I have code completion (qt 4.3.2). But it doesn't contain 'resize' method. (58.64 KB, image/png)
2008-04-05 18:34 UTC, soldatov
Details
Qt in NetBeans (screenshot) (34.01 KB, image/png)
2008-04-09 08:50 UTC, soldatov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description polzleitner 2008-04-05 15:29:27 UTC
I have the following setting: netbeans C++ extension, Qt installed on C:\Qt\4.3.4, Mingw compiler in C:\MinGw.
PATH set to PATH=C:\Qt\4.3.4\bin;C:\MinGW\bin;C:\WINDOWS\System32;C:\_E\cygwin\bin;

Include diretories C:\Qt\4.3.4\include\Qt, C:\Qt\4.3.4\include\QtCore, C:\Qt\4.3.4\include\Qt\UITools,
C:\Qt\4.3.4\include\QtGui have been added to both C and C++ code assistance.

To demonstrate type the following source:
    QPushButton hello;
    hello.|resize(100, 200);
The | shows a possible place for the cursor.
<Crtl><Space> shows: no suggestions.

Same behavior in netbeans 6.0 and 6.1.

In Linux: it is working correctly.
Comment 1 Vladimir Voskresensky 2008-04-05 15:54:27 UTC
thanks, we'll investigate. 
Use Unix for now ;-)
Comment 2 soldatov 2008-04-05 18:34:24 UTC
Created attachment 59733 [details]
But I have code completion (qt 4.3.2). But it doesn't contain 'resize' method.
Comment 3 polzleitner 2008-04-05 19:18:31 UTC
Could the issue be a recursion problem, when the code completion module scans the header files? 

I discovered the following while trying to code complete a QPushButton:

Situtation 1: Source line is 
#include <QPushButton>

Typing out the contents of the file QPushButton yields
C:\Qt\4.3.4\include\QtGui>type QPushButton
#include "qpushbutton.h"

C:\Qt\4.3.4\include\QtGui>type qpushbutton.h
#include "../../src/gui/widgets/qpushbutton.h"

This shows that finding the final definitions for the QPushButton class requires a look-up through several #include files.

When I #include a header that requires only ONE recursion it works:

Situation 2: 
Here the source line is 
#include <qpushButton.h>

C:\Qt\4.3.4\include\Qt>type qpushbutton.h
#include "../../src/gui/widgets/qpushbutton.h"

THEN CODE COMPLETION WORKS!

(Remark: both the C:\Qt\4.3.4\include\Qt, and C:\Qt\4.3.4\include\QtGui directories are in my "code assistance directory
list").

Maybe this helps to resolve the bug.

Cheers,
Wolfgang




Comment 4 soldatov 2008-04-05 20:00:48 UTC
Can you try such scenario?

- Add 'C:\Qt\4.3.4\include' path into C++ code assistance also
- Close NetBeans
- Delete old cache in C:\Documents and Settings\<USER>\Local Settings\Temp\<USER>-cnd60-caches-0\
- Verify code completion again
Comment 5 polzleitner 2008-04-05 21:58:37 UTC
This WORKED in Netbeans 6.1, although not in Netbeans 6.0.1.

One strange thing remains:

  QPushButton hello;
  hello.set|Text("hello ");
  hello.res|ize(150, 100);

setText is code-completed alright, the resize method still refuses to get completed. It does so without any
problems in Linux (even Netbeans 6.0). I noticed, however, that the Linux Qt includes do not use recursion so
excessively. So there is a difference between Qt in different OSes.

But your suggestion brought a big step forward in Windows.

Many thanks!
Comment 6 polzleitner 2008-04-06 12:18:50 UTC
So here is another follow-up. QPushButton is a subclass of QWidget. The missing resize method is from QWidget.

Now QWidget is ignored by code completion completely:

1. #include <QWid|get>
2. int main(int argc, char *argv[]) {
3.    QWid|get *w = new QWidget();
4.    w->|resize(500,500);

Line 1: Suggests QWidget C:\Qt\4.3.4\include\QtGui
Line 3: Suggests QWidgetData, QWidgetMap, etc. but not just QWidget
Line 4: no suggestions

The sequence of #include files is
C:\Qt\4.3.4\include\QtGui>type QWidget
#include "qwidget.h"

C:\Qt\4.3.4\include\QtGui>type qwidget.h
#include "../../src/gui/kernel/qwidget.h"

C:\Qt\4.3.4\include\QtGui>type ..\..\src\gui\kernel\qwidget.h
... Here is the actual header information ... omitted because it is very long
... The file contains e.g. the resize method definition ...

There might be some strange things in this qwidget.h file the parser does not understand? 
Can the parser be replaced or is it a netbeans built-in?


I have all the includes as suggested in the previous comment.
I now start netbeans from a .bat file which first empties out the temp directory:

C:\Qt\4.3.4\bin>type netbeans-6.1.bat
PATH=C:\Qt\4.3.4\bin;C:\MinGW\bin;C:\WINDOWS\System32;C:\_E\cygwin\bin;
del /S /F /Q "C:\Documents and Settings\wp\Local Settings\Temp"
"c:\Documents and Settings\All Users\Start Menu\Programs\NetBeans\NetBeans IDE 6.1 Beta.lnk"





Comment 7 soldatov 2008-04-06 13:17:49 UTC
I found bad string (Qt 4.3.2).

- Open D:\Qt\4.3.2\src\gui\kernelqwidget.h file
- Find 'friend Q_GUI_EXPORT QWidgetData *qt_qwidget_data(QWidget *widget);' line
- Comment this line
- Close NetBeans
- Delete old cache in C:\Documents and Settings\<USER>\Local Settings\Temp\<USER>-cnd60-caches-0\
- Verify code completion again
Comment 8 soldatov 2008-04-06 13:45:44 UTC
Parser fails on such code (simple testcase):

#define Q_DECL_IMPORT __declspec(dllimport)
#define Q_GUI_EXPORT Q_DECL_IMPORT

class QWidgetData {
public:
    QWidgetData() {}
};

class QObject {
public:
    QObject() {}
};

class QPaintDevice {
public:
    QPaintDevice() {}
};

class Q_GUI_EXPORT QWidget : public QObject, public QPaintDevice {
public:
    int i;
    friend Q_GUI_EXPORT QWidgetData *qt_qwidget_data(QWidget *widget);
};
Comment 9 Vladimir Kvashin 2008-04-06 17:22:06 UTC
It is *at least* a P2 bug,
since the class QWidget from the example above disappears from the model completely.
It's field "i" is shown as a global variable.
Comment 10 Vladimir Kvashin 2008-04-06 17:26:07 UTC
The reason is understood: the parser breaks on the __declspec(dllimport) construct.
I think it's easy to fix.
Comment 11 Vladimir Voskresensky 2008-04-06 19:13:15 UTC
I agree, it's easy to fix and very preferable to have in 6.1 as well.
I will fix grammar
Comment 12 Vladimir Voskresensky 2008-04-07 06:24:49 UTC
fixed in trunk 
http://hg.netbeans.org/main?cmd=changeset;node=8c89deab0e63
+ test
 http://hg.netbeans.org/main?cmd=changeset;node=333fa8bf487d

Please, review and approve integrating into 6.1
Comment 13 Vladimir Kvashin 2008-04-07 15:27:12 UTC
I reviewed the test. 
I agree that it's correct and safe.
Comment 14 soldatov 2008-04-07 15:55:46 UTC
verified in 200804040802 build + jars with fixes from developers
Comment 15 Vladimir Voskresensky 2008-04-07 16:07:14 UTC
fix integrated in 6.1
http://hg.netbeans.org/release61?cmd=changeset;node=2d8f60a678f1
Comment 16 soldatov 2008-04-08 07:51:50 UTC
Bug not fixed. '__declspec' is predefined macro on Windows.

Platform independent testcase:

# 1 "newfile.cpp"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "newfile.cpp"



class QWidgetData {
public:
    QWidgetData() {}
};

class QObject {
public:
    QObject() {}
};

class QPaintDevice {
public:
    QPaintDevice() {}
};

class __attribute__((dllimport)) QWidget : public QObject, public QPaintDevice {
public:
    int i;
    friend __attribute__((dllimport)) QWidgetData *qt_qwidget_data(QWidget *widget);
};
Comment 17 Vladimir Voskresensky 2008-04-08 09:36:40 UTC
From your example I see, that it's not predefined, but otherwise :-)
If you generated output by gcc => gcc has:
#define __declspec(x)   __attribute__((x)) 
Comment 19 soldatov 2008-04-09 08:42:59 UTC
verified in 200804082140 build (branch: release61)
Comment 20 soldatov 2008-04-09 08:50:11 UTC
Created attachment 59885 [details]
Qt in NetBeans (screenshot)