Disconnect signals in destructor to avoid the assert

Closes #20272.
This commit is contained in:
xtemp09
2025-03-26 20:24:48 +07:00
committed by Benjamin Nauck
parent bac9ef0fcc
commit 9d9ee7d9c3
2 changed files with 10 additions and 4 deletions

View File

@@ -139,14 +139,15 @@ EditorView::EditorView(TextEdit* editor, QWidget* parent)
d->activityTimer = new QTimer(this);
// clang-format off
connectionList <<
connect(d->activityTimer, &QTimer::timeout,
this, &EditorView::checkTimestamp);
this, &EditorView::checkTimestamp) <<
connect(d->textEdit->document(), &QTextDocument::modificationChanged,
this, &EditorView::setWindowModified);
this, &EditorView::setWindowModified) <<
connect(d->textEdit->document(), &QTextDocument::undoAvailable,
this, &EditorView::undoAvailable);
this, &EditorView::undoAvailable) <<
connect(d->textEdit->document(), &QTextDocument::redoAvailable,
this, &EditorView::redoAvailable);
this, &EditorView::redoAvailable) <<
connect(d->textEdit->document(), &QTextDocument::contentsChange,
this, &EditorView::contentsChange);
// clang-format on
@@ -156,6 +157,10 @@ EditorView::EditorView(TextEdit* editor, QWidget* parent)
EditorView::~EditorView()
{
d->activityTimer->stop();
// to avoid the assert introduced a debug version of Qt >6.3. See QTBUG-105473
for (auto conn : connectionList) { // NOLINT(performance-for-range-copy)
disconnect(conn);
}
delete d->activityTimer;
delete d;
getWindowParameter()->Detach(this);

View File

@@ -116,6 +116,7 @@ private:
private:
EditorViewP* d;
QList <QMetaObject::Connection> connectionList;
};
class PythonEditor;