From 64b493cb6f34ad93aaf11b11f7b247ac84c2b5dd Mon Sep 17 00:00:00 2001 From: =?utf8?q?CHEMIN=20S=C3=A9bastien=20236498?= Date: Wed, 29 May 2024 08:27:22 +0200 Subject: [PATCH] Add shared ptr for foreground objects --- src/QtViewer/QtViewer_ViewPort.cxx | 10 +++++++++- src/QtViewer/QtViewer_ViewPort.h | 5 +++-- 2 files changed, 12 insertions(+), 3 deletions(-) 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 -- 2.39.2