From 1858385952637e60d3c5fc66959036b299b190dd Mon Sep 17 00:00:00 2001 From: jkriege2 Date: Fri, 2 Feb 2024 11:35:00 +0100 Subject: [PATCH] FIXED issue #118: "Dangerous warning in MacOS and clang" (thanks to user:igormironchik for reporting): a forward-declared class (i.e. incomplete type) was deleted --- doc/dox/whatsnew.dox | 1 + lib/jkqtmathtext/jkqtmathtext.cpp | 9 +++++++-- lib/jkqtmathtext/jkqtmathtext.h | 8 ++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/doc/dox/whatsnew.dox b/doc/dox/whatsnew.dox index 3ed7639911..d7108f0906 100644 --- a/doc/dox/whatsnew.dox +++ b/doc/dox/whatsnew.dox @@ -130,6 +130,7 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
  • FIXED/IMPROVED: JKQTMathText renders several LaTeX strings better (simple braces in math mode, \c +-*... as symbols with proper sizes in math mode, added some missing instruction aliases, improved size of \\vec and \\hat, corrrected fonts usage for \\mathrm
  • FIXED: \c \\sum and \c \\prod used the wrong symbol in XITS-mode
  • FIXED issue #117: Unnecessary printing of tilde symbol in math (thanks to user:igormironchik for reporting):
    Tilde was not recognized as a LaTeX instruction, now is interpreted as non-breaking whitespace
  • +
  • FIXED issue #118: Dangerous warning in MacOS and clang (thanks to user:igormironchik for reporting):
    a forward-declared class (i.e. incomplete type) was deleted
  • IMPROVED: high-dpr-support in JKQTMathText
  • IMPROVED: typesetting of sub-/supercripts, especially for large math operators and braces
  • MODIFIED: brace node now calculates the extension of the child height above or below the strikeoutPos, in order to center braces around the strikeoutPos
  • diff --git a/lib/jkqtmathtext/jkqtmathtext.cpp b/lib/jkqtmathtext/jkqtmathtext.cpp index b1910d7ef7..3433aea5cd 100644 --- a/lib/jkqtmathtext/jkqtmathtext.cpp +++ b/lib/jkqtmathtext/jkqtmathtext.cpp @@ -202,8 +202,7 @@ JKQTMathText::JKQTMathText(QObject* parent, bool useFontsForGUI): } JKQTMathText::~JKQTMathText() { - if (parsedNode!=nullptr) delete parsedNode; - parsedNode=nullptr; + deleteParsedNode(); } void JKQTMathText::loadSettings(const QSettings& settings, const QString& group){ @@ -1195,6 +1194,12 @@ void JKQTMathText::clearErrorList() error_list.clear(); } +void JKQTMathText::deleteParsedNode() +{ + if (parsedNode) delete parsedNode; + parsedNode=nullptr; +} + const JKQTMathTextNode *JKQTMathText::getNodeTree() const { return this->parsedNode; diff --git a/lib/jkqtmathtext/jkqtmathtext.h b/lib/jkqtmathtext/jkqtmathtext.h index 0a6815fad0..79e3e6a2f6 100644 --- a/lib/jkqtmathtext/jkqtmathtext.h +++ b/lib/jkqtmathtext/jkqtmathtext.h @@ -242,9 +242,8 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { inline bool parse(const QString &markup, ParseOptions options=DefaultParseOptions) { static_assert(std::is_base_of::value, "in parse() the type TParser has to be derived from JKQTMathTextParser to work!"); std::unique_ptr p=std::unique_ptr(new TParser(this)); - if (parsedNode) delete parsedNode; - parsedNode=nullptr; - clearErrorList(); + deleteParsedNode(); + clearErrorList(); parsedNode=p->parse(markup, options); return parsedNode!=nullptr; } @@ -878,7 +877,8 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { /** \brief the syntax tree of JKQTMathTextNode's that was created by the last parse() call */ JKQTMathTextNode* parsedNode; - + /** \brief this function moves a delete parsedNode-call into the cpp-file, as JKQTMathTextNode is "only" forward declared here and therefore, deleting it may cause undefined behaviour */ + void deleteParsedNode(); /** \brief table with font replacements to use (e.g. if it is known that a certain font is not good for rendering, you can add