Skip to content

Commit

Permalink
Replace use of deprecated std::auto_ptr with QScopedPointer
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 14, 2015
1 parent a4ee405 commit 9cdb640
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 11 deletions.
9 changes: 3 additions & 6 deletions src/core/qgsproject.cpp
Expand Up @@ -354,7 +354,7 @@ QgsProject::~QgsProject()
delete mRelationManager;
delete mRootGroup;

// note that std::auto_ptr automatically deletes imp_ when it's destroyed
// note that QScopedPointer automatically deletes imp_ when it's destroyed
} // QgsProject dtor


Expand Down Expand Up @@ -818,8 +818,7 @@ bool QgsProject::read()
{
clearError();

std::auto_ptr< QDomDocument > doc =
std::auto_ptr < QDomDocument > ( new QDomDocument( "qgis" ) );
QScopedPointer<QDomDocument> doc( new QDomDocument( "qgis" ) );

if ( !imp_->file.open( QIODevice::ReadOnly | QIODevice::Text ) )
{
Expand Down Expand Up @@ -1064,9 +1063,7 @@ bool QgsProject::write()
QDomDocumentType documentType =
DomImplementation.createDocumentType( "qgis", "http://mrcc.com/qgis.dtd",
"SYSTEM" );
std::auto_ptr < QDomDocument > doc =
std::auto_ptr < QDomDocument > ( new QDomDocument( documentType ) );

QScopedPointer<QDomDocument> doc( new QDomDocument( documentType ) );

QDomElement qgisNode = doc->createElement( "qgis" );
qgisNode.setAttribute( "projectname", title() );
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsproject.h
Expand Up @@ -400,7 +400,7 @@ class CORE_EXPORT QgsProject : public QObject
struct Imp;

/// implementation handle
std::auto_ptr<Imp> imp_;
QScopedPointer<Imp> imp_;

static QgsProject * theProject_;

Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgisgui.cpp
Expand Up @@ -137,7 +137,7 @@ namespace QgisGui
}
#else
//create a file dialog using the filter list generated above
std::auto_ptr<QFileDialog> fileDialog( new QFileDialog( theParent, theMessage, initialPath, QStringList( filterMap.keys() ).join( ";;" ) ) );
QScopedPointer<QFileDialog> fileDialog( new QFileDialog( theParent, theMessage, initialPath, QStringList( filterMap.keys() ).join( ";;" ) ) );

// allow for selection of more than one file
fileDialog->setFileMode( QFileDialog::AnyFile );
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsmapcanvas.cpp
Expand Up @@ -288,7 +288,7 @@ QgsMapCanvas::~QgsMapCanvas()
mScene->deleteLater(); // crashes in python tests on windows

delete mMapRenderer;
// mCanvasProperties auto-deleted via std::auto_ptr
// mCanvasProperties auto-deleted via QScopedPointer
// CanvasProperties struct has its own dtor for freeing resources

if ( mJob )
Expand Down
4 changes: 2 additions & 2 deletions src/gui/qgsmapcanvas.h
Expand Up @@ -555,7 +555,7 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
class CanvasProperties;

/// Handle pattern for implementation object
std::auto_ptr<CanvasProperties> mCanvasProperties;
QScopedPointer<CanvasProperties> mCanvasProperties;

/**debugging member
invoked when a connect() is made to this object
Expand All @@ -570,7 +570,7 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
/**
@note
Otherwise std::auto_ptr would pass the object responsiblity on to the
Otherwise QScopedPointer would pass the object responsiblity on to the
copy like a hot potato leaving the copyer in a weird state.
*/
QgsMapCanvas( QgsMapCanvas const & );
Expand Down

0 comments on commit 9cdb640

Please sign in to comment.