After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 727608 - Compilation failure if qt4 doesn't have STL support
Compilation failure if qt4 doesn't have STL support
Status: RESOLVED FIXED
Product: NetworkManager
Classification: Platform
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: NetworkManager maintainer(s)
NetworkManager maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2014-04-04 13:52 UTC by Vicente Olivert Riera
Modified: 2014-04-07 09:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[PATCH] don't use toStdString() in qt demo (1.41 KB, patch)
2014-04-04 15:10 UTC, Thomas Haller
none Details | Review

Description Vicente Olivert Riera 2014-04-04 13:52:36 UTC
During the configure phase NetworkManager checks if Qt is installed. If the detection is successful, then it passes the option --enable-qt which builds an example program located in examples/C/qt/monitor-nm-running.cpp

That program uses toStdString(), which is only available when Qt is compiled with STL support. Check this:
   http://developer.qt.nokia.com/doc/qt-4.8/qstring.html#toStdString

So, checking if Qt is installed is not enough. It also needs to check if the installed Qt has STL support.

To do that, the configure scrip could do a compilation test of a simple program like this one:

#include <QtCore/QtGlobal>
#ifdef QT_NO_STL
#error "No STL"
#endif
int main() {}

And compile it with:

g++ -I$(qmake -query QT_INSTALL_HEADERS) -c check_for_qt_stl.cpp
Comment 1 Thomas Haller 2014-04-04 15:10:03 UTC
Created attachment 273591 [details] [review]
[PATCH] don't use toStdString() in qt demo

Wouldn't it be simpler just to fix the example program?

I don't have QT installed. Does the attached patch fix the issue?
Comment 2 Vicente Olivert Riera 2014-04-04 16:51:59 UTC
(In reply to comment #1)
> Created an attachment (id=273591) [details] [review]
> [PATCH] don't use toStdString() in qt demo
> 
> Wouldn't it be simpler just to fix the example program?
> 
> I don't have QT installed. Does the attached patch fix the issue?

No, calling .constData() doesn't produce the same result:


$ cat test.cpp 
#include <iostream>
#include <QtCore/QString>

int main() {
  QString my_string = "hello world";
  std::cout << "with toStdString() " << my_string.toStdString() << std::endl;
  std::cout << "with constData() " << my_string.constData() << std::endl;
}

$ g++ -I$(qmake-qt4 -query QT_INSTALL_HEADERS) -lQtCore test.cpp -o test

$ ./test 
with toStdString() hello world
with constData() 0xf3d25a
Comment 3 Vicente Olivert Riera 2014-04-04 17:05:45 UTC
If you change .toStdString() by .toUtf8().constData() works.
Comment 4 Thomas Haller 2014-04-04 21:30:22 UTC
I pushed the commit to upstream master: http://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=2748bcfebff927bc2bae988d42e143e3fd68445c


(actually, I accidentally pushed the wrong patch to master. That's the reason for the rush now, to fix it).



I think this bug is resolved now. If there is something not working, please reopen. Thanks!!
Comment 5 Vicente Olivert Riera 2014-04-07 09:47:51 UTC
You are welcome :)