Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compile errors with Qt 5.3.2 and Boost 1.55.0 #10039

Merged
merged 2 commits into from
Mar 21, 2017

Conversation

ryanofsky
Copy link
Contributor

Both errors were introduced in #9974 and reported by @paveljanik

Construct scoped_connection directly instead of relying on copy initialization
and move constructor. Avoids the following compile error in debian jessie:

```
In file included from /usr/include/boost/signals2/signal.hpp:21:0,
                 from ./util.h:29,
                 from ./dbwrapper.h:11,
                 from ./txdb.h:10,
                 from ./test/test_bitcoin.h:11,
                 from qt/test/wallettests.cpp:11:
/usr/include/boost/signals2/connection.hpp: In function ‘uint256 {anonymous}::SendCoins(CWallet&, SendCoinsDialog&, const CBitcoinAddress&, CAmount)’:
/usr/include/boost/signals2/connection.hpp:234:7: error: ‘boost::signals2::scoped_connection::scoped_connection(const boost::signals2::scoped_connection&)’ is private
       scoped_connection(const scoped_connection &other);
       ^
qt/test/wallettests.cpp:47:6: error: within this context
     });
      ^
```

Error reported by Pavel Janík <Pavel@Janik.cz> in
bitcoin#9974 (comment)
Construct QTimer object directly, instead of relying on QTimer::singleShot
overloads accepting lambdas, which weren't introduced until Qt 5.4.

Avoids the following compile error in debian jessie:

```
qt/test/wallettests.cpp: In function ‘void {anonymous}::ConfirmSend()’:
qt/test/wallettests.cpp:34:6: error: no matching function for call to ‘QTimer::singleShot(int, Qt::TimerType, {anonymous}::ConfirmSend()::<lambda()>)’
     });
      ^
qt/test/wallettests.cpp:34:6: note: candidates are:
In file included from /usr/include/x86_64-linux-gnu/qt5/QtCore/QTimer:1:0,
                 from ./qt/sendcoinsdialog.h:13,
                 from qt/test/wallettests.cpp:7:
/usr/include/x86_64-linux-gnu/qt5/QtCore/qtimer.h:81:17: note: static void QTimer::singleShot(int, const QObject*, const char*)
     static void singleShot(int msec, const QObject *receiver, const char *member);
                 ^
/usr/include/x86_64-linux-gnu/qt5/QtCore/qtimer.h:81:17: note:   no known conversion for argument 2 from ‘Qt::TimerType’ to ‘const QObject*’
/usr/include/x86_64-linux-gnu/qt5/QtCore/qtimer.h:82:17: note: static void QTimer::singleShot(int, Qt::TimerType, const QObject*, const char*)
     static void singleShot(int msec, Qt::TimerType timerType, const QObject *receiver, const char *member);
                 ^
/usr/include/x86_64-linux-gnu/qt5/QtCore/qtimer.h:82:17: note:   candidate expects 4 arguments, 3 provided
```

Error reported by Pavel Janík <Pavel@Janik.cz> in
bitcoin#9974 (comment)
@paveljanik
Copy link
Contributor

Going to test this. Thanks!

@paveljanik
Copy link
Contributor

paveljanik commented Mar 20, 2017

Compiles OK on Debian Jessie and openSUSE (gcc 4.8.5, 5.3.1 and 6.2.1).

ACK b5bec4e

@fanquake fanquake added the Bug label Mar 21, 2017
@laanwj laanwj merged commit b5bec4e into bitcoin:master Mar 21, 2017
laanwj added a commit that referenced this pull request Mar 21, 2017
b5bec4e Avoid QTimer::singleShot compile error with Qt 5.3.2 (Russell Yanofsky)
d5046e7 Avoid scoped_connection compile error with boost 1.55.0 (Russell Yanofsky)

Tree-SHA512: 96362b872817681b062e05c8fcb76cfc23b6e87e0371584a6aae0e17535fd34ccdba922380aa4b669a8e75ef3f9fadd25061541f77cb3198173f04249a7bcd62
@pstratem
Copy link
Contributor

pstratem commented Mar 26, 2017

This change breaks compiling on debian 8.7 with qt4 ( 4:4.8.6+git64-g5dc8b2b+dfsg-3+deb8u1 ).

I suspect one version works in qt4 and the other in qt5.

@pstratem
Copy link
Contributor

@ryanofsky ping

@jonasschnelli
Copy link
Contributor

Maybe it's time to think about dropping support to compile against Qt4? We already dropped support during runtime...

@laanwj
Copy link
Member

laanwj commented Mar 27, 2017

Maybe it's time to think about dropping support to compile against Qt4? We already dropped support during runtime...

The issue for discussion that is #8263

ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Mar 27, 2017
Unlike Qt5, the Qt4 signals implementation doesn't allow a signal to be
directly connected to a c++ lambda expression. Work around this by defining a
Callback QObject with a virtual method that can forward calls to a closure.

The Qt4 error was reported by Patrick Strateman <patrick.strateman@gmail.com>
in bitcoin#10039 (comment)
QTimer::singleShot(0, Qt::PreciseTimer, []() {
QTimer* timer = new QTimer;
timer->setSingleShot(true);
QObject::connect(timer, &QTimer::timeout, []() {
Copy link
Contributor

@gmaxwell gmaxwell Apr 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fails to compile for me on debian testing with qt/test/wallettests.cpp:36:6: error: no matching function for call to ‘QObject::connect(QTimer*&, void (QTimer::*)(),
{anonymous}::ConfirmSend()::<lambda()>)’ });

(edit, actually reverting this commit by itself and it fails elsewhere with qt/test/wallettests.cpp:25:27: error: ‘PreciseTimer’ is not a member of ‘Qt’
QTimer::singleShot(0, Qt::PreciseTimer, {)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#10098 fixes this

HashUnlimited pushed a commit to chaincoin/chaincoin that referenced this pull request Feb 28, 2018
Unlike Qt5, the Qt4 signals implementation doesn't allow a signal to be
directly connected to a c++ lambda expression. Work around this by defining a
Callback QObject with a virtual method that can forward calls to a closure.

The Qt4 error was reported by Patrick Strateman <patrick.strateman@gmail.com>
in bitcoin#10039 (comment)
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Mar 14, 2019
b5bec4e Avoid QTimer::singleShot compile error with Qt 5.3.2 (Russell Yanofsky)
d5046e7 Avoid scoped_connection compile error with boost 1.55.0 (Russell Yanofsky)

Tree-SHA512: 96362b872817681b062e05c8fcb76cfc23b6e87e0371584a6aae0e17535fd34ccdba922380aa4b669a8e75ef3f9fadd25061541f77cb3198173f04249a7bcd62
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request May 20, 2019
b5bec4e Avoid QTimer::singleShot compile error with Qt 5.3.2 (Russell Yanofsky)
d5046e7 Avoid scoped_connection compile error with boost 1.55.0 (Russell Yanofsky)

Tree-SHA512: 96362b872817681b062e05c8fcb76cfc23b6e87e0371584a6aae0e17535fd34ccdba922380aa4b669a8e75ef3f9fadd25061541f77cb3198173f04249a7bcd62
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request May 21, 2019
b5bec4e Avoid QTimer::singleShot compile error with Qt 5.3.2 (Russell Yanofsky)
d5046e7 Avoid scoped_connection compile error with boost 1.55.0 (Russell Yanofsky)

Tree-SHA512: 96362b872817681b062e05c8fcb76cfc23b6e87e0371584a6aae0e17535fd34ccdba922380aa4b669a8e75ef3f9fadd25061541f77cb3198173f04249a7bcd62
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request May 21, 2019
b5bec4e Avoid QTimer::singleShot compile error with Qt 5.3.2 (Russell Yanofsky)
d5046e7 Avoid scoped_connection compile error with boost 1.55.0 (Russell Yanofsky)

Tree-SHA512: 96362b872817681b062e05c8fcb76cfc23b6e87e0371584a6aae0e17535fd34ccdba922380aa4b669a8e75ef3f9fadd25061541f77cb3198173f04249a7bcd62
barrystyle pushed a commit to PACGlobalOfficial/PAC that referenced this pull request Jan 22, 2020
b5bec4e Avoid QTimer::singleShot compile error with Qt 5.3.2 (Russell Yanofsky)
d5046e7 Avoid scoped_connection compile error with boost 1.55.0 (Russell Yanofsky)

Tree-SHA512: 96362b872817681b062e05c8fcb76cfc23b6e87e0371584a6aae0e17535fd34ccdba922380aa4b669a8e75ef3f9fadd25061541f77cb3198173f04249a7bcd62
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants