-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix segmentation fault when .conf file is missing
Whenever ghostwriter.conf is missing (or the last used exporter within is empty), the app will crash with a segmentation fault due to accessing an uninitialed pointer to the current HTML exporter in appsettings.cpp. This commit ensures that the pointer is initialized to null before being checked for whether obtaining an exporter was successful. BUG: 465799 (cherry picked from commit f82070a) Signed-off-by: Andreas Sturmlechner <[email protected]>
- Loading branch information
Showing
3 changed files
with
32 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2014-2023 Megan Conkle <[email protected]> | ||
/* | ||
* SPDX-FileCopyrightText: 2014-2024 Megan Conkle <[email protected]> | ||
* | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
*/ | ||
|
@@ -38,7 +38,7 @@ class HtmlPreviewPrivate | |
HtmlPreviewPrivate(HtmlPreview *q_ptr) | ||
: q_ptr(q_ptr) | ||
{ | ||
; | ||
proxy = new PreviewProxy(q_ptr); | ||
} | ||
|
||
~HtmlPreviewPrivate() | ||
|
@@ -51,7 +51,7 @@ class HtmlPreviewPrivate | |
MarkdownDocument *document; | ||
bool updateInProgress; | ||
bool updateAgain; | ||
PreviewProxy proxy; | ||
PreviewProxy *proxy; | ||
QString baseUrl; | ||
QRegularExpression headingTagExp; | ||
Exporter *exporter; | ||
|
@@ -91,7 +91,7 @@ HtmlPreview::HtmlPreview | |
d->updateInProgress = false; | ||
d->updateAgain = false; | ||
d->exporter = exporter; | ||
d->proxy.setMathEnabled(d->exporter->supportsMath()); | ||
d->proxy->setMathEnabled(d->exporter->supportsMath()); | ||
|
||
d->baseUrl = ""; | ||
|
||
|
@@ -153,7 +153,7 @@ HtmlPreview::HtmlPreview | |
this->setZoomFactor((horizontalDpi / 96.0)); | ||
|
||
QWebChannel *channel = new QWebChannel(this); | ||
channel->registerObject(QStringLiteral("previewProxy"), &d->proxy); | ||
channel->registerObject(QStringLiteral("previewProxy"), d->proxy); | ||
this->page()->setWebChannel(channel); | ||
|
||
QFile wrapperHtmlFile(":/resources/preview.html"); | ||
|
@@ -240,22 +240,22 @@ void HtmlPreview::setHtmlExporter(Exporter *exporter) | |
|
||
d->exporter = exporter; | ||
d->setHtmlContent(""); | ||
d->proxy.setMathEnabled(d->exporter->supportsMath()); | ||
d->proxy->setMathEnabled(d->exporter->supportsMath()); | ||
updatePreview(); | ||
} | ||
|
||
void HtmlPreview::setStyleSheet(const QString &css) | ||
{ | ||
Q_D(HtmlPreview); | ||
d->proxy.setStyleSheet(css); | ||
|
||
d->proxy->setStyleSheet(css); | ||
} | ||
|
||
void HtmlPreview::setMathEnabled(bool enabled) | ||
{ | ||
Q_D(HtmlPreview); | ||
d->proxy.setMathEnabled(enabled); | ||
|
||
d->proxy->setMathEnabled(enabled); | ||
} | ||
|
||
void HtmlPreviewPrivate::onHtmlReady() | ||
|
@@ -312,7 +312,7 @@ void HtmlPreview::closeEvent(QCloseEvent *event) | |
|
||
void HtmlPreviewPrivate::setHtmlContent(const QString &html) | ||
{ | ||
this->proxy.setHtmlContent(html); | ||
this->proxy->setHtmlContent(html); | ||
} | ||
|
||
QString HtmlPreviewPrivate::exportToHtml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters