Skip to content

Commit 7ee6044

Browse files
committed
Merge #14250: qt: Remove redundant stopThread() and stopExecutor() signals
24313fb Remove redundant stopExecutor() signal (Hennadii Stepanov) 1c0e0a5 Remove redundant stopThread() signal (Hennadii Stepanov) Pull request description: The `QThread::finished` signal do this work. Tree-SHA512: 1afce23d30232276d50c3af5af79d83b88e390a2b71f7df585cc1079585d330447d179bbc34c0a89599beb2da035dfd5b9ce23238171490825cabc3a19ae6e67
2 parents fcb6694 + 24313fb commit 7ee6044

File tree

6 files changed

+7
-16
lines changed

6 files changed

+7
-16
lines changed

src/qt/bitcoin.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ BitcoinApplication::~BitcoinApplication()
212212
if(coreThread)
213213
{
214214
qDebug() << __func__ << ": Stopping thread";
215-
Q_EMIT stopThread();
215+
coreThread->quit();
216216
coreThread->wait();
217217
qDebug() << __func__ << ": Stopped thread";
218218
}
@@ -279,8 +279,7 @@ void BitcoinApplication::startThread()
279279
connect(this, &BitcoinApplication::requestedInitialize, executor, &BitcoinCore::initialize);
280280
connect(this, &BitcoinApplication::requestedShutdown, executor, &BitcoinCore::shutdown);
281281
/* make sure executor object is deleted in its own thread */
282-
connect(this, &BitcoinApplication::stopThread, executor, &QObject::deleteLater);
283-
connect(this, &BitcoinApplication::stopThread, coreThread, &QThread::quit);
282+
connect(coreThread, &QThread::finished, executor, &QObject::deleteLater);
284283

285284
coreThread->start();
286285
}

src/qt/bitcoin.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ public Q_SLOTS:
9999
Q_SIGNALS:
100100
void requestedInitialize();
101101
void requestedShutdown();
102-
void stopThread();
103102
void splashFinished();
104103
void windowShown(BitcoinGUI* window);
105104

src/qt/intro.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ Intro::~Intro()
156156
{
157157
delete ui;
158158
/* Ensure thread is finished before it is deleted */
159-
Q_EMIT stopThread();
159+
thread->quit();
160160
thread->wait();
161161
}
162162

@@ -311,8 +311,7 @@ void Intro::startThread()
311311
connect(executor, &FreespaceChecker::reply, this, &Intro::setStatus);
312312
connect(this, &Intro::requestCheck, executor, &FreespaceChecker::check);
313313
/* make sure executor object is deleted in its own thread */
314-
connect(this, &Intro::stopThread, executor, &QObject::deleteLater);
315-
connect(this, &Intro::stopThread, thread, &QThread::quit);
314+
connect(thread, &QThread::finished, executor, &QObject::deleteLater);
316315

317316
thread->start();
318317
}

src/qt/intro.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ class Intro : public QDialog
5555

5656
Q_SIGNALS:
5757
void requestCheck();
58-
void stopThread();
5958

6059
public Q_SLOTS:
6160
void setStatus(int status, const QString &message, quint64 bytesAvailable);

src/qt/rpcconsole.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -688,8 +688,7 @@ void RPCConsole::setClientModel(ClientModel *model)
688688
}
689689
if (!model) {
690690
// Client model is being set to 0, this means shutdown() is about to be called.
691-
// Make sure we clean up the executor thread
692-
Q_EMIT stopExecutor();
691+
thread.quit();
693692
thread.wait();
694693
}
695694
}
@@ -975,11 +974,8 @@ void RPCConsole::startExecutor()
975974
// Requests from this object must go to executor
976975
connect(this, &RPCConsole::cmdRequest, executor, &RPCExecutor::request);
977976

978-
// On stopExecutor signal
979-
// - quit the Qt event loop in the execution thread
980-
connect(this, &RPCConsole::stopExecutor, &thread, &QThread::quit);
981-
// - queue executor for deletion (in execution thread)
982-
connect(&thread, &QThread::finished, executor, &RPCExecutor::deleteLater, Qt::DirectConnection);
977+
// Make sure executor object is deleted in its own thread
978+
connect(&thread, &QThread::finished, executor, &RPCExecutor::deleteLater);
983979

984980
// Default implementation of QThread::run() simply spins up an event loop in the thread,
985981
// which is what we want.

src/qt/rpcconsole.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ public Q_SLOTS:
132132

133133
Q_SIGNALS:
134134
// For RPC command executor
135-
void stopExecutor();
136135
void cmdRequest(const QString &command, const WalletModel* wallet_model);
137136

138137
private:

0 commit comments

Comments
 (0)