summary refs log tree commit diff
path: root/src/timeline
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2021-02-12 16:10:48 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2021-02-12 16:11:11 +0100
commit3c91b5b47befb588a7c8005745a1e8dadf47df03 (patch)
treecd05411f076dbfadab206403f1c46a1aa7f96040 /src/timeline
parentTranslated using Weblate (Hungarian) (diff)
downloadnheko-3c91b5b47befb588a7c8005745a1e8dadf47df03.tar.xz
Fix crash when editing an edited message pointing to itself
Diffstat (limited to 'src/timeline')
-rw-r--r--src/timeline/TimelineModel.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp
index b6ebeb84..0f35a290 100644
--- a/src/timeline/TimelineModel.cpp
+++ b/src/timeline/TimelineModel.cpp
@@ -1542,13 +1542,11 @@ TimelineModel::setEdit(QString newEdit)
         if (edit_ != newEdit) {
                 auto ev = events.get(newEdit.toStdString(), "");
                 if (ev && mtx::accessors::sender(*ev) == http::client()->user_id().to_string()) {
-                        edit_ = newEdit;
-                        emit editChanged(edit_);
-
+                        auto e = *ev;
                         setReply(QString::fromStdString(
-                          mtx::accessors::relations(*ev).reply_to().value_or("")));
+                          mtx::accessors::relations(e).reply_to().value_or("")));
 
-                        auto msgType = mtx::accessors::msg_type(*ev);
+                        auto msgType = mtx::accessors::msg_type(e);
                         if (msgType == mtx::events::MessageType::Text ||
                             msgType == mtx::events::MessageType::Notice) {
                                 input()->setText(relatedInfo(newEdit).quoted_body);
@@ -1557,11 +1555,15 @@ TimelineModel::setEdit(QString newEdit)
                         } else {
                                 input()->setText("");
                         }
+
+                        edit_ = newEdit;
                 } else {
-                        edit_ = "";
-                        emit editChanged(edit_);
+                        resetReply();
+
                         input()->setText("");
+                        edit_ = "";
                 }
+                emit editChanged(edit_);
         }
 }