Remove leak in ChatDocumentHandler

This commit is contained in:
Tobias Fella
2026-01-26 11:53:28 +01:00
committed by Tobias Fella
parent 37b8d8d813
commit 537ce772af

View File

@@ -28,7 +28,7 @@ class SyntaxHighlighter : public QSyntaxHighlighter
public: public:
QTextCharFormat mentionFormat; QTextCharFormat mentionFormat;
QTextCharFormat errorFormat; QTextCharFormat errorFormat;
Sonnet::BackgroundChecker *checker = new Sonnet::BackgroundChecker; Sonnet::BackgroundChecker checker;
Sonnet::Settings settings; Sonnet::Settings settings;
QList<QPair<int, QString>> errors; QList<QPair<int, QString>> errors;
QString previousText; QString previousText;
@@ -48,11 +48,11 @@ public:
errorFormat.setForeground(m_theme->negativeTextColor()); errorFormat.setForeground(m_theme->negativeTextColor());
errorFormat.setUnderlineStyle(QTextCharFormat::SpellCheckUnderline); errorFormat.setUnderlineStyle(QTextCharFormat::SpellCheckUnderline);
connect(checker, &Sonnet::BackgroundChecker::misspelling, this, [this](const QString &word, int start) { connect(&checker, &Sonnet::BackgroundChecker::misspelling, this, [this](const QString &word, int start) {
errors += {start, word}; errors += {start, word};
checker->continueChecking(); checker.continueChecking();
}); });
connect(checker, &Sonnet::BackgroundChecker::done, this, [this]() { connect(&checker, &Sonnet::BackgroundChecker::done, this, [this]() {
rehighlightTimer.start(); rehighlightTimer.start();
}); });
rehighlightTimer.setInterval(100); rehighlightTimer.setInterval(100);
@@ -64,9 +64,9 @@ public:
if (settings.checkerEnabledByDefault()) { if (settings.checkerEnabledByDefault()) {
if (text != previousText) { if (text != previousText) {
previousText = text; previousText = text;
checker->stop(); checker.stop();
errors.clear(); errors.clear();
checker->setText(text); checker.setText(text);
} }
for (const auto &error : errors) { for (const auto &error : errors) {
setFormat(error.first, error.second.size(), errorFormat); setFormat(error.first, error.second.size(), errorFormat);