From ff4124d1f09d15ba37f18f875c329ac9d71b784d Mon Sep 17 00:00:00 2001 From: blue Date: Tue, 12 Jan 2021 20:10:24 +0300 Subject: [PATCH] Resolved the bug about crash with an empty history chat --- core/rosteritem.cpp | 2 ++ ui/models/messagefeed.cpp | 7 ++++++- ui/models/messagefeed.h | 29 ++++++++++++++++------------- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/core/rosteritem.cpp b/core/rosteritem.cpp index 1baa61f..d51ae8b 100644 --- a/core/rosteritem.cpp +++ b/core/rosteritem.cpp @@ -134,6 +134,8 @@ void Core::RosterItem::nextRequest() last = true; } } + } else if (archiveState == empty && responseCache.size() == 0) { + last = true; } emit historyResponse(responseCache, last); } diff --git a/ui/models/messagefeed.cpp b/ui/models/messagefeed.cpp index ae17c7b..79d3755 100644 --- a/ui/models/messagefeed.cpp +++ b/ui/models/messagefeed.cpp @@ -137,8 +137,12 @@ QVariant Models::MessageFeed::data(const QModelIndex& index, int role) const answer = path; } } - case Attach: + break; + case Attach: { + ::Models::Attach att; + answer.setValue(att); + } break; case Bulk: { FeedItem item; @@ -169,6 +173,7 @@ QVariant Models::MessageFeed::data(const QModelIndex& index, int role) const } answer.setValue(item); } + break; default: break; } diff --git a/ui/models/messagefeed.h b/ui/models/messagefeed.h index af4bd6a..78d54ad 100644 --- a/ui/models/messagefeed.h +++ b/ui/models/messagefeed.h @@ -77,24 +77,12 @@ public: Bulk }; - enum Attachment { - none, - remote, - downloading, - uploading, - ready - }; private: enum SyncState { incomplete, syncing, complete }; - struct Attach { - Attachment state; - qreal progress; - QString localPath; - }; //tags struct id {}; @@ -135,6 +123,20 @@ private: static const QHash roles; }; +enum Attachment { + none, + remote, + downloading, + uploading, + ready +}; + +struct Attach { + Attachment state; + qreal progress; + QString localPath; +}; + struct FeedItem { QString text; QString sender; @@ -143,10 +145,11 @@ struct FeedItem { bool correction; QDateTime date; Shared::Message::State state; - MessageFeed::Attachment attach; + Attach attach; }; }; +Q_DECLARE_METATYPE(Models::Attach); Q_DECLARE_METATYPE(Models::FeedItem); #endif // MESSAGEFEED_H