TD: fix possible dangling pointer in QGIHighlight
This commit is contained in:
@@ -46,7 +46,6 @@ using namespace TechDraw;
|
||||
|
||||
QGIHighlight::QGIHighlight()
|
||||
{
|
||||
m_refText = "";
|
||||
m_refSize = 0.0;
|
||||
setInteractive(false);
|
||||
|
||||
@@ -97,7 +96,7 @@ void QGIHighlight::makeReference()
|
||||
prepareGeometryChange();
|
||||
m_refFont.setPixelSize(QGIView::calculateFontPixelSize(m_refSize));
|
||||
m_reference->setFont(m_refFont);
|
||||
m_reference->setPlainText(QString::fromUtf8(m_refText));
|
||||
m_reference->setPlainText(m_refText);
|
||||
double fudge = Rez::guiX(1.0);
|
||||
QPointF newPos(m_end.x() + fudge, m_start.y() - m_refSize - fudge);
|
||||
m_reference->setPos(newPos);
|
||||
@@ -126,9 +125,9 @@ void QGIHighlight::setBounds(double x1,double y1,double x2,double y2)
|
||||
m_end = QPointF(Rez::guiX(x2),Rez::guiX(-y2));
|
||||
}
|
||||
|
||||
void QGIHighlight::setReference(char* ref)
|
||||
void QGIHighlight::setReference(const char* ref)
|
||||
{
|
||||
m_refText = ref;
|
||||
m_refText = QString::fromUtf8(ref);
|
||||
}
|
||||
|
||||
void QGIHighlight::setFont(QFont f, double fsize)
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
QWidget * widget = nullptr ) override;
|
||||
|
||||
void setBounds(double x1,double y1,double x2,double y2);
|
||||
void setReference(char* sym);
|
||||
void setReference(const char* sym);
|
||||
void setFont(QFont f, double fsize);
|
||||
virtual void draw() override;
|
||||
void setInteractive(bool state);
|
||||
@@ -71,7 +71,7 @@ protected:
|
||||
/* bool m_dragging;*/
|
||||
|
||||
private:
|
||||
char* m_refText;
|
||||
QString m_refText;
|
||||
QGraphicsEllipseItem* m_circle;
|
||||
QGCustomRect* m_rect;
|
||||
QGCustomText* m_reference;
|
||||
|
||||
@@ -959,7 +959,7 @@ void QGIViewPart::drawHighlight(TechDraw::DrawViewDetail* viewDetail, bool b)
|
||||
QGIHighlight* highlight = new QGIHighlight();
|
||||
addToGroup(highlight);
|
||||
highlight->setPos(0.0,0.0); //sb setPos(center.x,center.y)?
|
||||
highlight->setReference(const_cast<char*>(viewDetail->Reference.getValue()));
|
||||
highlight->setReference(viewDetail->Reference.getValue());
|
||||
highlight->setStyle((Qt::PenStyle)vp->HighlightLineStyle.getValue());
|
||||
highlight->setColor(vp->HighlightLineColor.getValue().asValue<QColor>());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user