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

This commit is contained in:
jkriege2 2024-02-02 11:35:00 +01:00
parent acae5929d1
commit 1858385952
3 changed files with 12 additions and 6 deletions

View File

@ -130,6 +130,7 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
<li>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</li> <li>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</li>
<li>FIXED: \c \\sum and \c \\prod used the wrong symbol in XITS-mode</li> <li>FIXED: \c \\sum and \c \\prod used the wrong symbol in XITS-mode</li>
<li>FIXED issue <a href="https://github.com/jkriege2/JKQtPlotter/issues/117">#117: Unnecessary printing of tilde symbol in math</a> (thanks to <a href="https://github.com/igormironchik">user:igormironchik</a> for reporting):<br/>Tilde was not recognized as a LaTeX instruction, now is interpreted as non-breaking whitespace</li> <li>FIXED issue <a href="https://github.com/jkriege2/JKQtPlotter/issues/117">#117: Unnecessary printing of tilde symbol in math</a> (thanks to <a href="https://github.com/igormironchik">user:igormironchik</a> for reporting):<br/>Tilde was not recognized as a LaTeX instruction, now is interpreted as non-breaking whitespace</li>
<li>FIXED issue <a href="https://github.com/jkriege2/JKQtPlotter/issues/118">#118: Dangerous warning in MacOS and clang</a> (thanks to <a href="https://github.com/igormironchik">user:igormironchik</a> for reporting):<br/>a forward-declared class (i.e. incomplete type) was deleted</li>
<li>IMPROVED: high-dpr-support in JKQTMathText</li> <li>IMPROVED: high-dpr-support in JKQTMathText</li>
<li>IMPROVED: typesetting of sub-/supercripts, especially for large math operators and braces</li> <li>IMPROVED: typesetting of sub-/supercripts, especially for large math operators and braces</li>
<li>MODIFIED: brace node now calculates the extension of the child height above or below the strikeoutPos, in order to center braces around the strikeoutPos</li> <li>MODIFIED: brace node now calculates the extension of the child height above or below the strikeoutPos, in order to center braces around the strikeoutPos</li>

View File

@ -202,8 +202,7 @@ JKQTMathText::JKQTMathText(QObject* parent, bool useFontsForGUI):
} }
JKQTMathText::~JKQTMathText() { JKQTMathText::~JKQTMathText() {
if (parsedNode!=nullptr) delete parsedNode; deleteParsedNode();
parsedNode=nullptr;
} }
void JKQTMathText::loadSettings(const QSettings& settings, const QString& group){ void JKQTMathText::loadSettings(const QSettings& settings, const QString& group){
@ -1195,6 +1194,12 @@ void JKQTMathText::clearErrorList()
error_list.clear(); error_list.clear();
} }
void JKQTMathText::deleteParsedNode()
{
if (parsedNode) delete parsedNode;
parsedNode=nullptr;
}
const JKQTMathTextNode *JKQTMathText::getNodeTree() const { const JKQTMathTextNode *JKQTMathText::getNodeTree() const {
return this->parsedNode; return this->parsedNode;

View File

@ -242,8 +242,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject {
inline bool parse(const QString &markup, ParseOptions options=DefaultParseOptions) { inline bool parse(const QString &markup, ParseOptions options=DefaultParseOptions) {
static_assert(std::is_base_of<JKQTMathTextParser, TParser>::value, "in parse<TParser>() the type TParser has to be derived from JKQTMathTextParser to work!"); static_assert(std::is_base_of<JKQTMathTextParser, TParser>::value, "in parse<TParser>() the type TParser has to be derived from JKQTMathTextParser to work!");
std::unique_ptr<TParser> p=std::unique_ptr<TParser>(new TParser(this)); std::unique_ptr<TParser> p=std::unique_ptr<TParser>(new TParser(this));
if (parsedNode) delete parsedNode; deleteParsedNode();
parsedNode=nullptr;
clearErrorList(); clearErrorList();
parsedNode=p->parse(markup, options); parsedNode=p->parse(markup, options);
return parsedNode!=nullptr; 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 */ /** \brief the syntax tree of JKQTMathTextNode's that was created by the last parse() call */
JKQTMathTextNode* parsedNode; JKQTMathTextNode* parsedNode;
/** \brief this function moves a <code>delete parsedNode</code>-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 /** \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