FIXed slicing warning, by making the slice-operation explicit

This commit is contained in:
jkriege2 2024-01-11 14:22:46 +01:00
parent ef07a02e9b
commit f07c013c7f
8 changed files with 16 additions and 14 deletions

View File

@ -757,13 +757,13 @@ QString JKQTMathTextEnvironment::toHtmlAfter(JKQTMathTextEnvironment /*defaultEv
return "</span>";
}
JKQTMathTextNodeSize::JKQTMathTextNodeSize():
width(0),
baselineHeight(0),
overallHeight(0),
strikeoutPos(),
baselineXCorrection(0),
topXCorrection(0)
JKQTMathTextNodeSize::JKQTMathTextNodeSize(double width_, double baselineHeight_, double overallHeight_, double strikeoutPos_, double baselineXCorrection_, double topXCorrection_):
width(width_),
baselineHeight(baselineHeight_),
overallHeight(overallHeight_),
strikeoutPos(strikeoutPos_),
baselineXCorrection(baselineXCorrection_),
topXCorrection(topXCorrection_)
{
}

View File

@ -391,7 +391,7 @@ struct JKQTMATHTEXT_LIB_EXPORT JKQTMathTextEnvironment {
* \ingroup jkqtmathtext_tools
*/
struct JKQTMATHTEXT_LIB_EXPORT JKQTMathTextNodeSize {
JKQTMathTextNodeSize();
JKQTMathTextNodeSize(double width=0, double baselineHeight=0, double overallHeight=0, double strikeoutPos=0, double baselineXCorrection=0,double topXCorrection=0);
/** \brief width of whole block */
double width;
/** \brief baselineHeight of whole block, i.e. the ascent */
@ -419,6 +419,8 @@ struct JKQTMATHTEXT_LIB_EXPORT JKQTMathTextNodeSize {
inline QSizeF getSize() const { return QSizeF(width, overallHeight); }
/** \brief calculate the overall size in floating-point precision */
inline QSize getIntSize() const { return QSize(qCeil(width+1.0), qCeil(overallHeight+1.0)); }
/** \brief helper function, which generates a copy of this object, used to suppress slicing warning due to GSL E.63: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-slice */
inline JKQTMathTextNodeSize sliceToNodeSize() const { return *this; }
};
/** \brief summarizes all information available on a font for a specific MTenvironmentFont

View File

@ -49,7 +49,7 @@ JKQTMathTextBraceNode::~JKQTMathTextBraceNode() {
}
JKQTMathTextNodeSize JKQTMathTextBraceNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const {
return getSizeInternalAndBrace(painter, currentEv);
return getSizeInternalAndBrace(painter, currentEv).sliceToNodeSize();
}
JKQTMathTextBraceNode::NodeSize JKQTMathTextBraceNode::getSizeInternalAndBrace(QPainter &painter, JKQTMathTextEnvironment currentEv) const

View File

@ -369,7 +369,7 @@ JKQTMathTextMatrixNode::LayoutInfo JKQTMathTextMatrixNode::calcLayout(QPainter &
}
JKQTMathTextNodeSize JKQTMathTextMatrixNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const {
return calcLayout(painter, currentEv);
return calcLayout(painter, currentEv).sliceToNodeSize();
}
double JKQTMathTextMatrixNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const {

View File

@ -52,7 +52,7 @@ QString JKQTMathTextSymbolNode::getTypeName() const
JKQTMathTextNodeSize JKQTMathTextSymbolNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const {
return getSymbolSize(painter, currentEv);
return getSymbolSize(painter, currentEv).sliceToNodeSize();
}
QRectF JKQTMathTextSymbolNode::getBoundingRect(const QFont &f, const QString &text, GlobalSymbolFlags globalFlags, QPaintDevice *pd)

View File

@ -128,7 +128,7 @@ JKQTMathTextTextNode::JKQTMathTextTextNode(JKQTMathText* _parent, const QString&
JKQTMathTextTextNode::~JKQTMathTextTextNode() = default;
JKQTMathTextNodeSize JKQTMathTextTextNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const {
return calcLayout(painter, currentEv);
return calcLayout(painter, currentEv).sliceToNodeSize();
}
JKQTMathTextTextNode::LayoutInfo JKQTMathTextTextNode::calcLayout(QPainter &painter, JKQTMathTextEnvironment currentEv) const

View File

@ -124,7 +124,7 @@ bool JKQTMathTextVerbatimNode::toHtml(QString &html, JKQTMathTextEnvironment cur
JKQTMathTextNodeSize JKQTMathTextVerbatimNode::getSizeInternal(QPainter &painter, JKQTMathTextEnvironment currentEv) const
{
transformEnvironment(currentEv);
return calcLayout(painter, currentEv);
return calcLayout(painter, currentEv).sliceToNodeSize();
}
void JKQTMathTextVerbatimNode::transformEnvironment(JKQTMathTextEnvironment &currentEv) const

View File

@ -58,7 +58,7 @@ QString JKQTMathTextVerticalListNode::getTypeName() const
}
JKQTMathTextNodeSize JKQTMathTextVerticalListNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const {
return calcLayout(painter, currentEv);
return calcLayout(painter, currentEv).sliceToNodeSize();
}
JKQTMathTextVerticalListNode::LayoutInfo JKQTMathTextVerticalListNode::calcLayout(QPainter &painter, JKQTMathTextEnvironment ev) const