Skip to content

Commit

Permalink
Ban QScopedPointer/QSharedPointer
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 17, 2018
1 parent e1ace09 commit 6470aac
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 16 deletions.
3 changes: 3 additions & 0 deletions python/gui/auto_generated/qgsmapcanvas.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Map canvas is a class for displaying all GIS data types on a canvas.
Constructor
%End


~QgsMapCanvas();

double magnificationFactor() const;
Expand Down Expand Up @@ -1019,6 +1020,8 @@ called when panning is in action, reset indicates end of panning
called on resize or changed extent to notify canvas items to change their rectangle
%End

private:
QgsMapCanvas( QgsMapCanvas const & );
}; // class QgsMapCanvas


Expand Down
4 changes: 2 additions & 2 deletions src/3d/terrain/qgsdemterraintilegeometry_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ void DemTerrainTileGeometry::init()
// Each primitive has 3 vertives
mIndexAttribute->setCount( faces * 3 );

mVertexBuffer->setDataGenerator( QSharedPointer<PlaneVertexBufferFunctor>::create( mResolution, mSkirtHeight, mHeightMap ) );
mIndexBuffer->setDataGenerator( QSharedPointer<PlaneIndexBufferFunctor>::create( mResolution, mHeightMap ) );
mVertexBuffer->setDataGenerator( QSharedPointer<PlaneVertexBufferFunctor>::create( mResolution, mSkirtHeight, mHeightMap ) ); // skip-keyword-check
mIndexBuffer->setDataGenerator( QSharedPointer<PlaneIndexBufferFunctor>::create( mResolution, mHeightMap ) ); // skip-keyword-check

addAttribute( mPositionAttribute );
addAttribute( mTexCoordAttribute );
Expand Down
7 changes: 1 addition & 6 deletions src/gui/qgsmapcanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,9 @@ QgsMapCanvas::~QgsMapCanvas()

mScene->deleteLater(); // crashes in python tests on windows

// mCanvasProperties auto-deleted via QScopedPointer
// CanvasProperties struct has its own dtor for freeing resources

delete mCache;

delete mLabelingResults;

} // dtor
}

void QgsMapCanvas::setMagnificationFactor( double factor )
{
Expand Down
13 changes: 7 additions & 6 deletions src/gui/qgsmapcanvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
//! Constructor
QgsMapCanvas( QWidget *parent SIP_TRANSFERTHIS = nullptr );

//! QgsMapCanvas cannot be copied
QgsMapCanvas( const QgsMapCanvas &other ) = delete;
//! QgsMapCanvas cannot be copied
QgsMapCanvas &operator=( const QgsMapCanvas &other ) = delete;

~QgsMapCanvas() override;

/**
Expand Down Expand Up @@ -902,13 +907,9 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
private:
/// this class is non-copyable

/**
\note
Otherwise QScopedPointer would pass the object responsibility on to the
copy like a hot potato leaving the copyer in a weird state.
*/
#ifdef SIP_RUN
QgsMapCanvas( QgsMapCanvas const & );
#endif

//! encompases all map settings necessary for map rendering
QgsMapSettings mSettings;
Expand Down
2 changes: 1 addition & 1 deletion src/server/services/wms/qgswmsrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2798,7 +2798,7 @@ namespace QgsWms
QStringLiteral( "error message: %1. The XML string was: %2" ).arg( errorMsg, filter ) );
}
QDomElement filterElem = filterXml.firstChildElement();
QScopedPointer<QgsExpression> expression( QgsOgcUtils::expressionFromOgcFilter( filterElem, filteredLayer ) );
std::unique_ptr<QgsExpression> expression( QgsOgcUtils::expressionFromOgcFilter( filterElem, filteredLayer ) );
mFeatureFilter.setFilter( filteredLayer, *expression );
}
else
Expand Down
9 changes: 8 additions & 1 deletion tests/code_layout/test_banned_keywords.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,25 @@ HINTS[24]="Use std::swap instead"
KEYWORDS[25]="\bqUpperBound("
HINTS[25]="Use std::upper_bound instead"

KEYWORDS[26]="QScopedPointer"
HINTS[26]="Use std::unique_ptr instead"

KEYWORDS[27]="QSharedPointer"
HINTS[27]="Use std::shared_ptr instead"

RES=
DIR=$(git rev-parse --show-toplevel)

pushd "${DIR}" > /dev/null || exit

for i in "${!KEYWORDS[@]}"
do
FOUND=$(git grep "${KEYWORDS[$i]}" -- 'src/*.h' 'src/*.cpp' -- ':!*qtermwidget*')
FOUND=$(git grep "${KEYWORDS[$i]}" -- 'src/*.h' 'src/*.cpp' -- ':!*qtermwidget*' | grep --invert-match skip-keyword-check)

if [[ ${FOUND} ]]; then
echo "Found source files with banned keyword: ${KEYWORDS[$i]}!"
echo " -> ${HINTS[$i]}"
echo " or mark with // skip-keyword-check"
echo
echo "${FOUND}"
echo
Expand Down

0 comments on commit 6470aac

Please sign in to comment.