mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-21 19:30:26 +08:00
fix: fixed crash on moving/copying connections
This commit is contained in:
parent
d55f873f96
commit
9528cd6b28
@ -5,7 +5,15 @@
|
|||||||
#include "core/settings/SettingsBackend.hpp"
|
#include "core/settings/SettingsBackend.hpp"
|
||||||
|
|
||||||
#include <QListWidgetItem>
|
#include <QListWidgetItem>
|
||||||
|
#define GET_DATA(type, typeConv) \
|
||||||
|
[&](const QList<QListWidgetItem *> list) { \
|
||||||
|
QList<type> _list; \
|
||||||
|
for (const auto &item : list) \
|
||||||
|
{ \
|
||||||
|
_list.push_back(item->data(Qt::UserRole).to##typeConv()); \
|
||||||
|
} \
|
||||||
|
return _list; \
|
||||||
|
}
|
||||||
GroupManager::GroupManager(QWidget *parent) : QDialog(parent)
|
GroupManager::GroupManager(QWidget *parent) : QDialog(parent)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
@ -75,28 +83,23 @@ void GroupManager::onRCMActionTriggered_Copy()
|
|||||||
const auto _sender = qobject_cast<QAction *>(sender());
|
const auto _sender = qobject_cast<QAction *>(sender());
|
||||||
const GroupId groupId{ _sender->data().toString() };
|
const GroupId groupId{ _sender->data().toString() };
|
||||||
//
|
//
|
||||||
const auto &connectionList = connectionsList->selectedItems();
|
const auto list = GET_DATA(QString, String)(connectionsList->selectedItems());
|
||||||
for (const auto &connItem : connectionList)
|
for (const auto &connId : list)
|
||||||
{
|
{
|
||||||
const auto &connectionId = ConnectionId(connItem->data(Qt::UserRole).toString());
|
const auto &connectionId = ConnectionId(connId);
|
||||||
ConnectionManager->CreateConnection(GetDisplayName(connectionId), groupId, ConnectionManager->GetConnectionRoot(connectionId), true);
|
ConnectionManager->CreateConnection(GetDisplayName(connectionId), groupId, ConnectionManager->GetConnectionRoot(connectionId), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupManager::onRCMActionTriggered_Move()
|
void GroupManager::onRCMActionTriggered_Move()
|
||||||
{
|
{
|
||||||
const auto _sender = qobject_cast<QAction *>(sender());
|
const auto _sender = qobject_cast<QAction *>(sender());
|
||||||
const GroupId groupId{ _sender->data().toString() };
|
const GroupId groupId{ _sender->data().toString() };
|
||||||
//
|
//
|
||||||
const auto &connectionList = connectionsList->selectedItems();
|
const auto list = GET_DATA(QString, String)(connectionsList->selectedItems());
|
||||||
for (const auto &connItem : connectionList)
|
for (const auto &connId : list)
|
||||||
{
|
{
|
||||||
if (!connItem)
|
ConnectionManager->MoveConnectionGroup(ConnectionId(connId), groupId);
|
||||||
{
|
|
||||||
LOG(MODULE_UI, "Invalid?")
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const auto &id = connItem->data(Qt::UserRole);
|
|
||||||
ConnectionManager->MoveConnectionGroup(ConnectionId(id.toString()), groupId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,3 +240,4 @@ void GroupManager::on_connectionsList_customContextMenuRequested(const QPoint &p
|
|||||||
Q_UNUSED(pos)
|
Q_UNUSED(pos)
|
||||||
connectionListRCMenu->popup(QCursor::pos());
|
connectionListRCMenu->popup(QCursor::pos());
|
||||||
}
|
}
|
||||||
|
#undef GET_DATA
|
||||||
|
Loading…
Reference in New Issue
Block a user