cmake: avoid de-duplication of user's CXXFLAGS
[quassel.git] / src / qtui / topicwidget.cpp
index 033acaa..e9d71b7 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-2018 by the Quassel Project                        *
+ *   Copyright (C) 2005-2022 by the Quassel Project                        *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
@@ -152,13 +152,17 @@ void TopicWidget::setTopic(const QModelIndex& index)
         }
     }
 
-    _topic = sanitizeTopic(newtopic);
-    _readonly = readonly;
+    QString sanitizedNewTopic = sanitizeTopic(newtopic);
+    if (readonly != _readonly || sanitizedNewTopic != _topic)
+    {
+        _topic = sanitizedNewTopic;
+        _readonly = readonly;
 
-    ui.topicEditButton->setVisible(!_readonly);
-    ui.topicLabel->setText(_topic);
-    ui.topicLineEdit->setPlainText(_topic);
-    switchPlain();
+        ui.topicEditButton->setVisible(!_readonly);
+        ui.topicLabel->setText(_topic);
+        ui.topicLineEdit->setPlainText(_topic);
+        switchPlain();
+    }
 }
 
 void TopicWidget::setReadOnly(const bool& readonly)
@@ -257,7 +261,7 @@ bool TopicWidget::eventFilter(QObject* obj, QEvent* event)
 QString TopicWidget::sanitizeTopic(const QString& topic)
 {
     // Normally, you don't have new lines in topic messages
-    // But the use of "plain text" functionnality from Qt replaces
+    // But the use of "plain text" functionality from Qt replaces
     // some unicode characters with a new line, which then triggers
     // a stack overflow later
     QString result(topic);