mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-07-22 23:09:26 +00:00
fix(wallet): stop reachability checks while closed
This commit is contained in:
parent
969a98aa27
commit
7a09449371
@ -88,7 +88,6 @@ void WalletController::start()
|
||||
if (m_started)
|
||||
return;
|
||||
m_started = true;
|
||||
m_reachabilityTimer->start();
|
||||
QTimer::singleShot(0, this, &WalletController::openOnStartup);
|
||||
}
|
||||
|
||||
@ -207,6 +206,7 @@ bool WalletController::open()
|
||||
void WalletController::disconnect()
|
||||
{
|
||||
++m_operationGeneration;
|
||||
stopReachability();
|
||||
m_wallet.disconnect();
|
||||
m_state.isWalletOpen = false;
|
||||
m_state.syncStatus = QStringLiteral("closed");
|
||||
@ -276,9 +276,23 @@ void WalletController::applySnapshot(const WalletSnapshot& snapshot)
|
||||
if (!snapshot.sequencerAddress.isEmpty())
|
||||
m_state.sequencerAddress = snapshot.sequencerAddress;
|
||||
emit stateChanged();
|
||||
if (!m_reachabilityTimer->isActive())
|
||||
m_reachabilityTimer->start();
|
||||
checkReachability();
|
||||
}
|
||||
|
||||
void WalletController::stopReachability()
|
||||
{
|
||||
m_reachabilityTimer->stop();
|
||||
++m_reachabilityGeneration;
|
||||
if (m_reachabilityReply) {
|
||||
QNetworkReply* reply = m_reachabilityReply;
|
||||
m_reachabilityReply = nullptr;
|
||||
m_reachabilityEndpoint.clear();
|
||||
reply->abort();
|
||||
}
|
||||
}
|
||||
|
||||
void WalletController::checkReachability()
|
||||
{
|
||||
if (!m_state.isWalletOpen || m_state.sequencerAddress.isEmpty())
|
||||
|
||||
@ -65,6 +65,7 @@ private:
|
||||
bool beginOpen(const QString& config, const QString& storage);
|
||||
void applySnapshot(const WalletSnapshot& snapshot);
|
||||
void checkReachability();
|
||||
void stopReachability();
|
||||
|
||||
WalletProvider& m_wallet;
|
||||
QString m_settingsApplication;
|
||||
|
||||
@ -474,14 +474,17 @@ void LogosWalletProviderTest::controllerStopsReachabilityChecksAfterDisconnect()
|
||||
|
||||
QVERIFY(controller.open());
|
||||
QTRY_VERIFY_WITH_TIMEOUT(!finished.isEmpty(), 1000);
|
||||
controller.disconnect();
|
||||
finished.clear();
|
||||
|
||||
auto* timer = controller.findChild<QTimer*>();
|
||||
QVERIFY(timer);
|
||||
QVERIFY(timer->isActive());
|
||||
controller.disconnect();
|
||||
QVERIFY(!timer->isActive());
|
||||
finished.clear();
|
||||
|
||||
timer->setInterval(1);
|
||||
controller.start();
|
||||
QTest::qWait(50);
|
||||
QVERIFY(!timer->isActive());
|
||||
QCOMPARE(finished.count(), 0);
|
||||
|
||||
settings.clear();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user