Skip to content
Permalink
Browse files

Ban QScopedPointer/QSharedPointer

  • Loading branch information
nyalldawson committed Jun 17, 2018
1 parent e1ace09 commit 6470aacb3397ba119b0d6c29b5c83e28ecedae31
@@ -40,6 +40,7 @@ Map canvas is a class for displaying all GIS data types on a canvas.
Constructor
%End


~QgsMapCanvas();

double magnificationFactor() const;
@@ -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


@@ -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 );
@@ -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 )
{
@@ -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;

/**
@@ -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;
@@ -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
@@ -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

0 comments on commit 6470aac

Please sign in to comment.
You can’t perform that action at this time.