mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-01-06 15:04:34 +08:00
Fix processHash function
Fix processHash function to not use QVariantHash as result because of QJsonDocument doesn't support QVariantHash variables in Qt 5.
This commit is contained in:
parent
8931eec5b0
commit
28f573e9a8
@ -156,7 +156,7 @@ static const char KEY_SUFFIX_REMOVED[] = "_removed";
|
||||
QVariantMap getTranserInfoMap();
|
||||
QVariantMap toMap(const QTorrentHandle& h);
|
||||
void processMap(QVariantMap prevData, QVariantMap data, QVariantMap &syncData);
|
||||
void processHash(QVariantHash prevData, QVariantHash data, QVariantHash &syncData, QVariantList &removedItems);
|
||||
void processHash(QVariantHash prevData, QVariantHash data, QVariantMap &syncData, QVariantList &removedItems);
|
||||
void processList(QVariantList prevData, QVariantList data, QVariantList &syncData, QVariantList &removedItems);
|
||||
QVariantMap generateSyncData(int acceptedResponseId, QVariantMap data, QVariantMap &lastAcceptedData, QVariantMap &lastData);
|
||||
|
||||
@ -589,10 +589,10 @@ void processMap(QVariantMap prevData, QVariantMap data, QVariantMap &syncData)
|
||||
}
|
||||
break;
|
||||
case QVariant::Hash: {
|
||||
QVariantHash hash;
|
||||
processHash(prevData[key].toHash(), data[key].toHash(), hash, removedItems);
|
||||
if (!hash.isEmpty())
|
||||
syncData[key] = hash;
|
||||
QVariantMap map;
|
||||
processHash(prevData[key].toHash(), data[key].toHash(), map, removedItems);
|
||||
if (!map.isEmpty())
|
||||
syncData[key] = map;
|
||||
if (!removedItems.isEmpty())
|
||||
syncData[key + KEY_SUFFIX_REMOVED] = removedItems;
|
||||
}
|
||||
@ -626,7 +626,7 @@ void processMap(QVariantMap prevData, QVariantMap data, QVariantMap &syncData)
|
||||
// Compare two lists of structures (prevData, data) and calculate difference (syncData, removedItems).
|
||||
// Structures encoded as map.
|
||||
// Lists are encoded as hash table (indexed by structure key value) to improve ease of searching for removed items.
|
||||
void processHash(QVariantHash prevData, QVariantHash data, QVariantHash &syncData, QVariantList &removedItems)
|
||||
void processHash(QVariantHash prevData, QVariantHash data, QVariantMap &syncData, QVariantList &removedItems)
|
||||
{
|
||||
// initialize output variables
|
||||
syncData.clear();
|
||||
@ -634,7 +634,8 @@ void processHash(QVariantHash prevData, QVariantHash data, QVariantHash &syncDat
|
||||
|
||||
if (prevData.isEmpty()) {
|
||||
// If list was empty before, then difference is a whole new list.
|
||||
syncData = data;
|
||||
foreach (QString key, data.keys())
|
||||
syncData[key] = data[key];
|
||||
}
|
||||
else {
|
||||
foreach (QString key, data.keys()) {
|
||||
|
Loading…
Reference in New Issue
Block a user