diff --git a/src/RoomList.cpp b/src/RoomList.cpp
index 617710c41cb2a3f4d4ec798763533d29ddb6fea2..09250387889c28c5617be8bf030604e0616105e0 100644
--- a/src/RoomList.cpp
+++ b/src/RoomList.cpp
@@ -379,11 +379,11 @@ RoomList::sortRoomsByLastMessage()
 
         int newIndex = 0;
         for (const auto &roomWidget : rooms_sort_cache_) {
-                const auto currentIndex = contentsLayout_->indexOf(roomWidget.get());
+                const auto currentIndex = contentsLayout_->indexOf(roomWidget.data());
 
                 if (currentIndex != newIndex) {
-                        contentsLayout_->removeWidget(roomWidget.get());
-                        contentsLayout_->insertWidget(newIndex, roomWidget.get());
+                        contentsLayout_->removeWidget(roomWidget.data());
+                        contentsLayout_->insertWidget(newIndex, roomWidget.data());
                 }
                 newIndex++;
         }