From 7273bf9fb8dfbfabda48779a5612b68c2aadd7f9 Mon Sep 17 00:00:00 2001 From: Qv2ray-dev <59914293+Qv2ray-dev@users.noreply.github.com> Date: Sat, 14 Mar 2020 16:27:12 +0800 Subject: [PATCH] Revert "fix: some fixes when updating the subscription with exactly the same protocol/host/port pair but different name" This reverts commit 1cabc14835870962afe3ba7676c4e934fc356d9c. --- makespec/BUILDVERSION | 2 +- src/core/CoreSafeTypes.hpp | 10 +++++----- src/core/handler/ConfigHandler.cpp | 13 ++++++------- src/core/handler/ConfigHandler.hpp | 4 ++-- src/ui/w_MainWindow.cpp | 2 +- src/ui/w_MainWindow.hpp | 2 +- 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/makespec/BUILDVERSION b/makespec/BUILDVERSION index 87bdebd6..47f5014d 100644 --- a/makespec/BUILDVERSION +++ b/makespec/BUILDVERSION @@ -1 +1 @@ -4688 \ No newline at end of file +4687 \ No newline at end of file diff --git a/src/core/CoreSafeTypes.hpp b/src/core/CoreSafeTypes.hpp index ba6de988..283caa91 100644 --- a/src/core/CoreSafeTypes.hpp +++ b/src/core/CoreSafeTypes.hpp @@ -50,9 +50,9 @@ namespace Qv2ray::core inline const static auto NullGroupId = GroupId("null"); template - QSet StringsToIdSet(const QList &strings) + QList StringsToIdList(const QList &strings) { - QSet list; + QList list; for (auto str : strings) { @@ -63,7 +63,7 @@ namespace Qv2ray::core } template - QList IdListToStrings(const QSet &ids) + QList IdListToStrings(const QList &ids) { QList list; @@ -104,7 +104,7 @@ namespace Qv2ray::core { // Implicit base of two types, since group object is actually the group base object. bool isSubscription = false; - QSet connections; + QList connections; // Suger for down casting. GroupMetaObject() : connections() { @@ -114,7 +114,7 @@ namespace Qv2ray::core this->isSubscription = false; this->displayName = base.displayName; this->importDate = base.importDate; - this->connections = StringsToIdSet(base.connections); + this->connections = StringsToIdList(base.connections); } // Suger for down casting. GroupMetaObject(const SubscriptionObject_Config &base) : GroupMetaObject((GroupObject_Config) base) diff --git a/src/core/handler/ConfigHandler.cpp b/src/core/handler/ConfigHandler.cpp index 792effbf..1a36a7ec 100644 --- a/src/core/handler/ConfigHandler.cpp +++ b/src/core/handler/ConfigHandler.cpp @@ -223,7 +223,7 @@ namespace Qv2ray::core::handlers id.toString() + QV2RAY_CONFIG_FILE_EXTENSION); // connections.remove(id); - groups[groupId].connections.remove(id); + groups[groupId].connections.removeAll(id); emit OnConnectionDeleted(id, groupId); // bool exists = connectionFile.exists(); @@ -259,8 +259,8 @@ namespace Qv2ray::core::handlers { LOG(MODULE_FILEIO, "Cannot rename") } - groups[oldgid].connections.remove(id); - groups[newGroupId].connections << id; + groups[oldgid].connections.removeAll(id); + groups[newGroupId].connections.append(id); connections[id].groupId = newGroupId; // emit OnConnectionGroupChanged(id, oldgid, newGroupId); @@ -521,8 +521,7 @@ namespace Qv2ray::core::handlers groups[id].connections << _conn; UpdateConnection(_conn, config); // Remove Connection Id from the list. - connectionsOrig.remove(_conn); - typeMap.remove(typeMap.key(_conn)); + connectionsOrig.removeAll(_conn); } else if (canGetOutboundData && typeMap.contains(outboundData)) { @@ -533,8 +532,7 @@ namespace Qv2ray::core::handlers UpdateConnection(_conn, config); RenameConnection(_conn, _alias); // Remove Connection Id from the list. - connectionsOrig.remove(_conn); - nameMap.remove(nameMap.key(_conn)); + connectionsOrig.removeAll(_conn); } else { @@ -552,6 +550,7 @@ namespace Qv2ray::core::handlers LOG(MODULE_CORE_HANDLER, "Removing: " + conn.toString()) DeleteConnection(conn); } + // Update the time groups[id].lastUpdated = system_clock::to_time_t(system_clock::now()); diff --git a/src/core/handler/ConfigHandler.hpp b/src/core/handler/ConfigHandler.hpp index 9fbafe3d..286f9c98 100644 --- a/src/core/handler/ConfigHandler.hpp +++ b/src/core/handler/ConfigHandler.hpp @@ -40,7 +40,7 @@ namespace Qv2ray::core::handlers { return connections.keys(); } - inline const QSet Connections(const GroupId &groupId) const + inline const QList Connections(const GroupId &groupId) const { CheckGroupExistance(groupId); return groups[groupId].connections; @@ -124,7 +124,7 @@ namespace Qv2ray::core::handlers // void OnGroupCreated(const GroupId &id, const QString &displayName); void OnGroupRenamed(const GroupId &id, const QString &oldName, const QString &newName); - void OnGroupDeleted(const GroupId &id, const QSet &connections); + void OnGroupDeleted(const GroupId &id, const QList &connections); // void OnSubscriptionUpdateFinished(const GroupId &id); diff --git a/src/ui/w_MainWindow.cpp b/src/ui/w_MainWindow.cpp index 7300da79..c51523a9 100644 --- a/src/ui/w_MainWindow.cpp +++ b/src/ui/w_MainWindow.cpp @@ -854,7 +854,7 @@ void MainWindow::OnGroupCreated(const GroupId &id, const QString &displayName) Q_UNUSED(displayName) MWAddGroupItem_p(id); } -void MainWindow::OnGroupDeleted(const GroupId &id, const QSet &connections) +void MainWindow::OnGroupDeleted(const GroupId &id, const QList &connections) { for (auto conn : connections) { diff --git a/src/ui/w_MainWindow.hpp b/src/ui/w_MainWindow.hpp index d248f474..99ca277a 100644 --- a/src/ui/w_MainWindow.hpp +++ b/src/ui/w_MainWindow.hpp @@ -81,7 +81,7 @@ class MainWindow void OnConnectionGroupChanged(const ConnectionId &id, const GroupId &originalGroup, const GroupId &newGroup); // void OnGroupCreated(const GroupId &id, const QString &displayName); - void OnGroupDeleted(const GroupId &id, const QSet &connections); + void OnGroupDeleted(const GroupId &id, const QList &connections); // void on_action_StartThis_triggered(); void on_action_RCM_SetAutoConnection_triggered();