Skip to content

Commit b5bec4e

Browse files
committed
Avoid QTimer::singleShot compile error with Qt 5.3.2
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 <[email protected]> in bitcoin/bitcoin#9974 (comment)
1 parent d5046e7 commit b5bec4e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/qt/test/wallettests.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ namespace
2222
//! Press "Yes" button in modal send confirmation dialog.
2323
void ConfirmSend()
2424
{
25-
QTimer::singleShot(0, Qt::PreciseTimer, []() {
25+
QTimer* timer = new QTimer;
26+
timer->setSingleShot(true);
27+
QObject::connect(timer, &QTimer::timeout, []() {
2628
for (QWidget* widget : QApplication::topLevelWidgets()) {
2729
if (widget->inherits("SendConfirmationDialog")) {
2830
SendConfirmationDialog* dialog = qobject_cast<SendConfirmationDialog*>(widget);
@@ -32,6 +34,7 @@ void ConfirmSend()
3234
}
3335
}
3436
});
37+
timer->start(0);
3538
}
3639

3740
//! Send coins to address and return txid.

0 commit comments

Comments
 (0)