From 7f3095c9d8cceaf961cc3b331fd62641b466fad9 Mon Sep 17 00:00:00 2001
From: Nicolas Werner <nicolas.werner@hotmail.de>
Date: Sat, 16 Jul 2022 03:53:13 +0200
Subject: [PATCH] Fix subobject initialization

---
 src/timeline/CommunitiesModel.cpp | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/src/timeline/CommunitiesModel.cpp b/src/timeline/CommunitiesModel.cpp
index e254d7f9b..75f878c08 100644
--- a/src/timeline/CommunitiesModel.cpp
+++ b/src/timeline/CommunitiesModel.cpp
@@ -238,7 +238,7 @@ struct temptree
     void flatten(CommunitiesModel::FlatTree &to, int i = 0) const
     {
         for (const auto &[child, subtree] : children) {
-            to.tree.push_back({QString::fromStdString(child), i, false});
+            to.tree.push_back({QString::fromStdString(child), i, {}, false});
             subtree.flatten(to, i + 1);
         }
     }
@@ -275,15 +275,17 @@ CommunitiesModel::initializeSidebar()
     globalUnreads.notification_count = {};
     dmUnreads.notification_count     = {};
 
-    auto e = cache::client()->getAccountData(mtx::events::EventType::Direct);
-    if (e) {
-        if (auto event =
-              std::get_if<mtx::events::AccountDataEvent<mtx::events::account_data::Direct>>(
-                &e.value())) {
-            directMessages_.clear();
-            for (const auto &[userId, roomIds] : event->content.user_to_rooms)
-                for (const auto &roomId : roomIds)
-                    directMessages_.push_back(roomId);
+    {
+        auto e = cache::client()->getAccountData(mtx::events::EventType::Direct);
+        if (e) {
+            if (auto event =
+                  std::get_if<mtx::events::AccountDataEvent<mtx::events::account_data::Direct>>(
+                    &e.value())) {
+                directMessages_.clear();
+                for (const auto &[userId, roomIds] : event->content.user_to_rooms)
+                    for (const auto &roomId : roomIds)
+                        directMessages_.push_back(roomId);
+            }
         }
     }
 
-- 
GitLab