aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-11-23 15:38:06 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-11-23 15:55:16 +0900
commit64799eaf667840c7f81d80810508d948f64f97d6 (patch)
treefa16d293f20e5fc545b9711dfe8916ff64b854b9 /lib
parent53f3fe79ef91bb5ba318b61b3a073c12409abc72 (diff)
downloadlibquotient-64799eaf667840c7f81d80810508d948f64f97d6.tar.gz
libquotient-64799eaf667840c7f81d80810508d948f64f97d6.zip
Connection::saveState: use null instead of an empty object for a room
placeholder Otherwise placeholder objects are confused with normal room JSON objects when loading from the cache. Closes #257 (again).
Diffstat (limited to 'lib')
-rw-r--r--lib/connection.cpp11
-rw-r--r--lib/syncdata.cpp8
2 files changed, 7 insertions, 12 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp
index 7feeb075..53835a80 100644
--- a/lib/connection.cpp
+++ b/lib/connection.cpp
@@ -1104,15 +1104,8 @@ void Connection::saveState() const
QJsonObject rooms;
QJsonObject inviteRooms;
for (const auto* i : roomMap()) // Pass on rooms in Leave state
- {
- auto& targetArray = i->joinState() == JoinState::Invite
- ? inviteRooms : rooms;
- targetArray.insert(i->id(), QJsonObject());
- QElapsedTimer et1; et1.start();
- QCoreApplication::processEvents();
- if (et1.elapsed() > 1)
- qCDebug(PROFILER) << "processEvents() borrowed" << et1;
- }
+ (i->joinState() == JoinState::Invite ? inviteRooms : rooms)
+ .insert(i->id(), QJsonValue::Null);
QJsonObject roomObj;
if (!rooms.isEmpty())
diff --git a/lib/syncdata.cpp b/lib/syncdata.cpp
index d141a7cc..1023ed6a 100644
--- a/lib/syncdata.cpp
+++ b/lib/syncdata.cpp
@@ -156,9 +156,9 @@ void SyncData::parseJson(const QJsonObject& json, const QString& baseDir)
roomData.reserve(static_cast<size_t>(rs.size()));
for(auto roomIt = rs.begin(); roomIt != rs.end(); ++roomIt)
{
- auto roomJson = roomIt->isString()
- ? loadJson(baseDir + fileNameForRoom(roomIt.key()))
- : roomIt->toObject();
+ auto roomJson = roomIt->isObject()
+ ? roomIt->toObject()
+ : loadJson(baseDir + fileNameForRoom(roomIt.key()));
if (roomJson.isEmpty())
{
unresolvedRoomIds.push_back(roomIt.key());
@@ -171,6 +171,8 @@ void SyncData::parseJson(const QJsonObject& json, const QString& baseDir)
}
totalRooms += rs.size();
}
+ if (!unresolvedRoomIds.empty())
+ qCWarning(MAIN) << "Unresolved rooms:" << unresolvedRoomIds.join(',');
if (totalRooms > 9 || et.nsecsElapsed() >= profilerMinNsecs())
qCDebug(PROFILER) << "*** SyncData::parseJson(): batch with"
<< totalRooms << "room(s),"