File tree Expand file tree Collapse file tree 3 files changed +37
-5
lines changed Expand file tree Collapse file tree 3 files changed +37
-5
lines changed Original file line number Diff line number Diff line change @@ -122,6 +122,7 @@ QT_MOC_CPP = \
122
122
qt/moc_bitcoinamountfield.cpp \
123
123
qt/moc_bitcoingui.cpp \
124
124
qt/moc_bitcoinunits.cpp \
125
+ qt/moc_callback.cpp \
125
126
qt/moc_clientmodel.cpp \
126
127
qt/moc_coincontroldialog.cpp \
127
128
qt/moc_coincontroltreewidget.cpp \
@@ -167,6 +168,7 @@ BITCOIN_MM = \
167
168
QT_MOC = \
168
169
qt/bitcoin.moc \
169
170
qt/bitcoinamountfield.moc \
171
+ qt/callback.moc \
170
172
qt/intro.moc \
171
173
qt/overviewpage.moc \
172
174
qt/rpcconsole.moc
@@ -189,6 +191,7 @@ BITCOIN_QT_H = \
189
191
qt/bitcoinamountfield.h \
190
192
qt/bitcoingui.h \
191
193
qt/bitcoinunits.h \
194
+ qt/callback.h \
192
195
qt/clientmodel.h \
193
196
qt/coincontroldialog.h \
194
197
qt/coincontroltreewidget.h \
Original file line number Diff line number Diff line change
1
+ #ifndef BITCOIN_QT_CALLBACK_H
2
+ #define BITCOIN_QT_CALLBACK_H
3
+
4
+ #include < QObject>
5
+
6
+ class Callback : public QObject
7
+ {
8
+ Q_OBJECT
9
+ public Q_SLOTS:
10
+ virtual void call () = 0;
11
+ };
12
+
13
+ template <typename F>
14
+ class FunctionCallback : public Callback
15
+ {
16
+ F f;
17
+
18
+ public:
19
+ FunctionCallback (F f_) : f(std::move(f_)) {}
20
+ ~FunctionCallback () override {}
21
+ void call () override { f (this ); }
22
+ };
23
+
24
+ template <typename F>
25
+ FunctionCallback<F>* makeCallback (F f)
26
+ {
27
+ return new FunctionCallback<F>(std::move (f));
28
+ }
29
+
30
+ #endif // BITCOIN_QT_CALLBACK_H
Original file line number Diff line number Diff line change 1
1
#include " wallettests.h"
2
2
3
3
#include " qt/bitcoinamountfield.h"
4
+ #include " qt/callback.h"
4
5
#include " qt/optionsmodel.h"
5
6
#include " qt/platformstyle.h"
6
7
#include " qt/qvalidatedlineedit.h"
@@ -22,9 +23,7 @@ namespace
22
23
// ! Press "Yes" button in modal send confirmation dialog.
23
24
void ConfirmSend ()
24
25
{
25
- QTimer* timer = new QTimer;
26
- timer->setSingleShot (true );
27
- QObject::connect (timer, &QTimer::timeout, []() {
26
+ QTimer::singleShot (0 , makeCallback ([](Callback* callback) {
28
27
for (QWidget* widget : QApplication::topLevelWidgets ()) {
29
28
if (widget->inherits (" SendConfirmationDialog" )) {
30
29
SendConfirmationDialog* dialog = qobject_cast<SendConfirmationDialog*>(widget);
@@ -33,8 +32,8 @@ void ConfirmSend()
33
32
button->click ();
34
33
}
35
34
}
36
- }) ;
37
- timer-> start ( 0 );
35
+ delete callback ;
36
+ }), SLOT ( call ()) );
38
37
}
39
38
40
39
// ! Send coins to address and return txid.
You can’t perform that action at this time.
0 commit comments