Skip to content

Commit

Permalink
Connection::saveState: use null instead of an empty object for a room
Browse files Browse the repository at this point in the history
placeholder

Otherwise placeholder objects are confused with normal room JSON objects
when loading from the cache. Closes #257 (again).
  • Loading branch information
KitsuneRal committed Nov 23, 2018
1 parent 53f3fe7 commit 64799ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
11 changes: 2 additions & 9 deletions lib/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
8 changes: 5 additions & 3 deletions lib/syncdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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),"
Expand Down

0 comments on commit 64799ea

Please sign in to comment.