File rhbz1861171b.patch of Package choqok

From 2f5cc98e4904ca0a45fb982b15e28ac7e56c6dd5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Bri=C3=A8re?= <fbriere@fbriere.net>
Date: Sun, 19 Jun 2022 05:25:54 -0400
Subject: [PATCH] Disconnect configChanged() signal from *Settings in
 QWidget-based dtors

Because the QWidget dtor will delete its children first, it is the
responsability of any subclass to disconnect any signal that might be
emitted as a result of a child's destruction.  Otherwise, that signal
could end up attempting to invoke a method on the now-destroyed parent.

The ChoqokTabBar, QuickPost and TextEdit dtors put various settings in
AppearanceSettings or BehaviorSettings, which may end up triggering a
configChanged() signal.  Therefore, all QWidget subclasses that have
connected this signal should disconnect it in their dtor.

(Technically, this is only required of *parents* of the above classes,
so it could be omitted from TextEdit.  Still, better safe than sorry.)

BUG: 418312
---
 choqok/mainwindow.cpp           | 5 +++++
 libchoqok/ui/choqoktextedit.cpp | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/choqok/mainwindow.cpp b/choqok/mainwindow.cpp
index 00c18aa2..5f02fb87 100644
--- a/choqok/mainwindow.cpp
+++ b/choqok/mainwindow.cpp
@@ -96,6 +96,11 @@ MainWindow::MainWindow(ChoqokApplication *application)
 MainWindow::~MainWindow()
 {
     qCDebug(CHOQOK);
+
+    disconnect(Choqok::BehaviorSettings::self(), &Choqok::BehaviorSettings::configChanged,
+               this, &MainWindow::slotBehaviorConfigChanged);
+    disconnect(Choqok::AppearanceSettings::self(), &Choqok::AppearanceSettings::configChanged,
+               this, &MainWindow::slotAppearanceConfigChanged);
 }
 
 void MainWindow::loadAllAccounts()
diff --git a/libchoqok/ui/choqoktextedit.cpp b/libchoqok/ui/choqoktextedit.cpp
index 83c42c80..161edc15 100644
--- a/libchoqok/ui/choqoktextedit.cpp
+++ b/libchoqok/ui/choqoktextedit.cpp
@@ -76,6 +76,9 @@ TextEdit::TextEdit(uint charLimit /*= 0*/, QWidget *parent /*= 0*/)
 
 TextEdit::~TextEdit()
 {
+    disconnect(BehaviorSettings::self(), &BehaviorSettings::configChanged,
+               this, &TextEdit::settingsChanged);
+
     BehaviorSettings::setSpellerLanguage(d->curLang);
     d->langActions->deleteLater();
     delete d;
-- 
GitLab

openSUSE Build Service is sponsored by