From 67e734a87e14e75186822e084b8e11da6a2dea12 Mon Sep 17 00:00:00 2001 From: reionwong Date: Sat, 10 Oct 2026 13:40:56 +0800 Subject: [PATCH] fix(network): report a hotspot activation removed before its reply --- network/handler.cpp | 5 +++-- network/tests/fakenetworkmanager.h | 4 ++++ network/tests/tst_networkclient.cpp | 11 +++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/network/handler.cpp b/network/handler.cpp index 45705ec..f9ac6ef 100644 --- a/network/handler.cpp +++ b/network/handler.cpp @@ -496,8 +496,9 @@ void Handler::hotspotRequestFinished(const QDBusMessage &reply, int activePathAr if (state == ActiveActivated) return; m_hotspotActivation = active; - // Its state may have changed before this reply arrived. - if (state == ActiveDeactivated || state == ActiveDeactivating) + // Its state may have changed, or NetworkManager removed it, before this reply arrived. + const bool gone = m_client->ready() && !m_client->has(active, activeInterface); + if (gone || state == ActiveDeactivated || state == ActiveDeactivating) activeStateChanged(active, ActiveDeactivated); } diff --git a/network/tests/fakenetworkmanager.h b/network/tests/fakenetworkmanager.h index d716eab..87e503a 100644 --- a/network/tests/fakenetworkmanager.h +++ b/network/tests/fakenetworkmanager.h @@ -306,6 +306,8 @@ public: const QString activeConnection = activate(profile, args.value(1).value().path(), args.value(2).value().path()); + if (dropActivations) + remove(activeConnection); reply << FakeNM::path(profile) << FakeNM::path(activeConnection); } else if (member == QStringLiteral("ActivateConnection")) { reply << FakeNM::path(activate(args.value(0).value().path(), @@ -349,6 +351,8 @@ public: QHash settings; QHash secrets; QSet privateConnections; + // Activations fail and vanish before their reply is sent. + bool dropActivations = false; QMap permissions; QList calls; diff --git a/network/tests/tst_networkclient.cpp b/network/tests/tst_networkclient.cpp index eaf4821..9c6aef6 100644 --- a/network/tests/tst_networkclient.cpp +++ b/network/tests/tst_networkclient.cpp @@ -415,6 +415,17 @@ private slots: QTRY_COMPARE(failed.size(), 1); } + void hotspotGoneBeforeReplyIsReported() + { + Handler handler; + QTRY_VERIFY(handler.hotspotCapable()); + QSignalSpy failed(&handler, &Handler::hotspotFailed); + nm->dropActivations = true; + handler.createHotspot(); + QTRY_COMPARE(failed.size(), 1); + QVERIFY(!handler.hotspotActive()); + } + void hotspotNamesTheNetworkItWouldEnd() { Handler handler;