refactor: move iOS/macOS NE specific disconnect logic to the top of disconnectFromVpn method (#2100)

This commit is contained in:
yyy-amnezia
2025-12-27 05:09:11 +02:00
committed by GitHub
parent a4c4ef71fb
commit 6bac948633

View File

@@ -537,6 +537,12 @@ QString VpnConnection::bytesPerSecToText(quint64 bytes)
void VpnConnection::disconnectFromVpn()
{
#if defined(Q_OS_IOS) || defined(MACOS_NE)
// iOS/macOS NE use IosController directly; m_vpnProtocol is not set there.
IosController::Instance()->disconnectVpn();
disconnect(&m_checkTimer, &QTimer::timeout, IosController::Instance(), &IosController::checkStatus);
#endif
if (m_vpnProtocol.isNull()) {
emit connectionStateChanged(Vpn::ConnectionState::Disconnected);
return;
@@ -573,11 +579,6 @@ void VpnConnection::disconnectFromVpn()
m_vpnProtocol->stop();
#endif
#if defined(Q_OS_IOS) || defined(MACOS_NE)
IosController::Instance()->disconnectVpn();
disconnect(&m_checkTimer, &QTimer::timeout, IosController::Instance(), &IosController::checkStatus);
#endif
#if !defined(Q_OS_ANDROID) && !defined(AMNEZIA_DESKTOP)
m_vpnProtocol->deleteLater();
#endif