From: CHEMIN Sébastien 236498 Date: Wed, 29 May 2024 06:27:22 +0000 (+0200) Subject: Add shared ptr for foreground objects X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=64b493cb6f34ad93aaf11b11f7b247ac84c2b5dd;p=modules%2Fgui.git Add shared ptr for foreground objects --- diff --git a/src/QtViewer/QtViewer_ViewPort.cxx b/src/QtViewer/QtViewer_ViewPort.cxx index 040f79516..b741c4b2f 100644 --- a/src/QtViewer/QtViewer_ViewPort.cxx +++ b/src/QtViewer/QtViewer_ViewPort.cxx @@ -76,11 +76,19 @@ QtViewer_ViewPort::~QtViewer_ViewPort() zoomCursor = nullptr; } +void QtViewer_ViewPort::resetForeground() +{ + for (std::shared_ptr obj : foregroundObjects) + obj.reset(); + + foregroundObjects.clear(); +} + void QtViewer_ViewPort::drawForeground(QPainter *painter, const QRectF &rect) { Q_UNUSED(rect); - for (QtViewer_PainterObject* obj : foregroundObjects) + for (std::shared_ptr obj : foregroundObjects) obj->draw(painter); } diff --git a/src/QtViewer/QtViewer_ViewPort.h b/src/QtViewer/QtViewer_ViewPort.h index e419c91e3..200ea383d 100644 --- a/src/QtViewer/QtViewer_ViewPort.h +++ b/src/QtViewer/QtViewer_ViewPort.h @@ -59,7 +59,8 @@ public: QImage dumpView(bool theWholeScene = false, QSizeF theSize = QSizeF()); bool dumpViewToFormat(const QString& fileName, const QString& format); - void addForegroundObject(QtViewer_PainterObject* obj) { foregroundObjects.append(obj); } + void addForegroundObject( std::shared_ptr obj) { foregroundObjects.append(obj); } + void resetForeground(); signals: void vpMouseEvent(QMouseEvent*); @@ -95,7 +96,7 @@ private: QPoint previousPos; QCursor* zoomCursor; - QList foregroundObjects; + QList > foregroundObjects; }; #endif