Skip to content

Commit

Permalink
qgs3dmapcanvaswidget: Use QObjectUniquePtr for frustum rubberband
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitjano authored and nyalldawson committed Mar 23, 2023
1 parent fc39f9c commit f4d1984
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
12 changes: 5 additions & 7 deletions src/app/3d/qgs3dmapcanvaswidget.cpp
Expand Up @@ -55,7 +55,6 @@
Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked )
: QWidget( nullptr )
, mCanvasName( name )
, mViewFrustumHighlight( nullptr )
{
const QgsSettings setting;

Expand Down Expand Up @@ -272,8 +271,6 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked )
Qgs3DMapCanvasWidget::~Qgs3DMapCanvasWidget()
{
delete mDockableWidgetHelper;
if ( mViewFrustumHighlight )
delete mViewFrustumHighlight;
}

void Qgs3DMapCanvasWidget::resizeEvent( QResizeEvent *event )
Expand Down Expand Up @@ -384,10 +381,11 @@ void Qgs3DMapCanvasWidget::setMainCanvas( QgsMapCanvas *canvas )
connect( mMainCanvas, &QgsMapCanvas::canvasColorChanged, this, &Qgs3DMapCanvasWidget::onMainCanvasColorChanged );
connect( mMainCanvas, &QgsMapCanvas::extentsChanged, this, &Qgs3DMapCanvasWidget::onMainMapCanvasExtentChanged );

if ( mViewFrustumHighlight )
delete mViewFrustumHighlight;
mViewFrustumHighlight = new QgsRubberBand( canvas, Qgis::GeometryType::Polygon );
mViewFrustumHighlight->setColor( QColor::fromRgba( qRgba( 0, 0, 255, 50 ) ) );
if ( !mViewFrustumHighlight )
{
mViewFrustumHighlight.reset( new QgsRubberBand( canvas, Qgis::GeometryType::Polygon ) );
mViewFrustumHighlight->setColor( QColor::fromRgba( qRgba( 0, 0, 255, 50 ) ) );
}
}

void Qgs3DMapCanvasWidget::resetView()
Expand Down
3 changes: 2 additions & 1 deletion src/app/3d/qgs3dmapcanvaswidget.h
Expand Up @@ -19,6 +19,7 @@
#include "qmenu.h"
#include "qgsdockwidget.h"
#include "qgis_app.h"
#include "qobjectuniqueptr.h"
#include "qtoolbutton.h"
#include "qgsrectangle.h"

Expand Down Expand Up @@ -116,7 +117,7 @@ class APP_EXPORT Qgs3DMapCanvasWidget : public QWidget
QAction *mShowFrustumPolyogon = nullptr;
QToolButton *mBtnOptions = nullptr;
QgsDockableWidgetHelper *mDockableWidgetHelper = nullptr;
QgsRubberBand *mViewFrustumHighlight = nullptr;
QObjectUniquePtr< QgsRubberBand > mViewFrustumHighlight;
QPointer<QDialog> mConfigureDialog;
};

Expand Down

0 comments on commit f4d1984

Please sign in to comment.