Skip to content

Commit

Permalink
Set initial state correctly and add some safety measures (pbek#2622)
Browse files Browse the repository at this point in the history
  • Loading branch information
pbek committed Oct 11, 2022
1 parent 3a18a22 commit 707ffa5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# QOwnNotes Changelog

## 22.10.1
- disabling of the Markdown highlighting now also works after a restart of
the application (for [#2622](https://github.com/pbek/QOwnNotes/issues/2622))

## 22.10.0
- Exporting and printing of the selected text in the note text edit now really only
- exporting and printing of the selected text in the note text edit now really only
uses the selected text again (for [#2618](https://github.com/pbek/QOwnNotes/issues/2618))

## 22.9.2
Expand Down
14 changes: 11 additions & 3 deletions src/widgets/qownnotesmarkdowntextedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ QOwnNotesMarkdownTextEdit::QOwnNotesMarkdownTextEdit(QWidget *parent)
: QMarkdownTextEdit(parent, false) {
mainWindow = nullptr;

// We need to set the internal variable to true, because we start with a highlighter
_highlightingEnabled = true;
_highlighter = nullptr;
if (parent->objectName() != QStringLiteral("LogWidget")) {
_highlighter = new QOwnNotesMarkdownHighlighter(document());
Expand Down Expand Up @@ -110,7 +112,9 @@ void QOwnNotesMarkdownTextEdit::setFormatStyle(
MarkdownHighlighter::HighlighterState index) {
QTextCharFormat format;
Utils::Schema::schemaSettings->setFormatStyle(index, format);
_highlighter->setTextFormat(index, format);
if (_highlighter) {
_highlighter->setTextFormat(index, format);
}
}

/**
Expand Down Expand Up @@ -304,7 +308,9 @@ int QOwnNotesMarkdownTextEdit::modifyFontSize(FontModificationMode mode) {

if (doSetStyles) {
this->setStyles();
_highlighter->rehighlight();
if (_highlighter) {
_highlighter->rehighlight();
}
}

return fontSize;
Expand Down Expand Up @@ -885,7 +891,9 @@ void QOwnNotesMarkdownTextEdit::updateSettings() {
if (highlightingEnabled) {
// set the new highlighting styles
setStyles();
_highlighter->rehighlight();
if (_highlighter) {
_highlighter->rehighlight();
}
}
}

Expand Down

0 comments on commit 707ffa5

Please sign in to comment.