From abd30fb774f6d0cd5abf93019f652c0ca54778f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= Date: Thu, 9 Apr 2015 03:37:24 +0200 Subject: [PATCH] s/auto_ptr/unique_ptr/ The old auto_ptr was used for simple RAII. None of the auto_ptr flaws were apparent in that context, but given that that class is actively deprecated and that compilers warn about its use, it's better to switch to its drop-in replacement. My reason for not using QScopedPointer is that the C++11 version works well enough, Okular is being built in C++11 mode anyway, unique_ptr works on the KF5-minimal-mandated-compilers according to their docs, and therefore there's no point in using something with a different API (QScopedPointer) just because its name begins with a Q. REVIEW: 124027 --- core/document.cpp | 8 ++++---- generators/comicbook/directory.cpp | 2 +- generators/comicbook/unrar.cpp | 2 +- part.cpp | 2 +- ui/guiutils.cpp | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core/document.cpp b/core/document.cpp index 34218f574..665844be3 100644 --- a/core/document.cpp +++ b/core/document.cpp @@ -4363,7 +4363,7 @@ Document::OpenResult Document::openDocumentArchive( const QString & docFile, con if ( !mainEntry || !mainEntry->isFile() ) return OpenError; - std::auto_ptr< QIODevice > mainEntryDevice( static_cast< const KZipFileEntry * >( mainEntry )->createDevice() ); + std::unique_ptr< QIODevice > mainEntryDevice( static_cast< const KZipFileEntry * >( mainEntry )->createDevice() ); QDomDocument doc; if ( !doc.setContent( mainEntryDevice.get() ) ) return OpenError; @@ -4397,7 +4397,7 @@ Document::OpenResult Document::openDocumentArchive( const QString & docFile, con if ( !docEntry || !docEntry->isFile() ) return OpenError; - std::auto_ptr< ArchiveData > archiveData( new ArchiveData() ); + std::unique_ptr< ArchiveData > archiveData( new ArchiveData() ); const int dotPos = documentFileName.indexOf( '.' ); if ( dotPos != -1 ) archiveData->document.setFileTemplate(QDir::tempPath() + QLatin1String("/okular_XXXXXX") + documentFileName.mid(dotPos)); @@ -4406,7 +4406,7 @@ Document::OpenResult Document::openDocumentArchive( const QString & docFile, con QString tempFileName = archiveData->document.fileName(); { - std::auto_ptr< QIODevice > docEntryDevice( static_cast< const KZipFileEntry * >( docEntry )->createDevice() ); + std::unique_ptr< QIODevice > docEntryDevice( static_cast< const KZipFileEntry * >( docEntry )->createDevice() ); copyQIODevice( docEntryDevice.get(), &archiveData->document ); archiveData->document.close(); } @@ -4414,7 +4414,7 @@ Document::OpenResult Document::openDocumentArchive( const QString & docFile, con const KArchiveEntry * metadataEntry = mainDir->entry( metadataFileName ); if ( metadataEntry && metadataEntry->isFile() ) { - std::auto_ptr< QIODevice > metadataEntryDevice( static_cast< const KZipFileEntry * >( metadataEntry )->createDevice() ); + std::unique_ptr< QIODevice > metadataEntryDevice( static_cast< const KZipFileEntry * >( metadataEntry )->createDevice() ); archiveData->metadataFile.setFileTemplate(QDir::tempPath() + QLatin1String("/okular_XXXXXX.xml")); if ( archiveData->metadataFile.open() ) { diff --git a/generators/comicbook/directory.cpp b/generators/comicbook/directory.cpp index ec023b37f..260424762 100644 --- a/generators/comicbook/directory.cpp +++ b/generators/comicbook/directory.cpp @@ -58,7 +58,7 @@ QStringList Directory::list() const QIODevice* Directory::createDevice( const QString &path ) const { - std::auto_ptr file( new QFile( path ) ); + std::unique_ptr file( new QFile( path ) ); if ( !file->open( QIODevice::ReadOnly ) ) return 0; diff --git a/generators/comicbook/unrar.cpp b/generators/comicbook/unrar.cpp index 731305fee..1edabbe86 100644 --- a/generators/comicbook/unrar.cpp +++ b/generators/comicbook/unrar.cpp @@ -165,7 +165,7 @@ QIODevice* Unrar::createDevice( const QString &fileName ) const if ( !isSuitableVersionAvailable() ) return 0; - std::auto_ptr< QFile> file( new QFile( mTempDir->path() + '/' + fileName ) ); + std::unique_ptr< QFile> file( new QFile( mTempDir->path() + '/' + fileName ) ); if ( !file->open( QIODevice::ReadOnly ) ) return 0; diff --git a/part.cpp b/part.cpp index 05590e8d5..b650c9ff3 100644 --- a/part.cpp +++ b/part.cpp @@ -181,7 +181,7 @@ static QString compressedMimeFor( const QString& mime_to_check ) const QString app_xz( QString::fromLatin1( "application/x-xz" ) ); if ( compressedMimeMap.isEmpty() ) { - std::auto_ptr< KFilterBase > f; + std::unique_ptr< KFilterBase > f; compressedMimeMap[ QString::fromLatin1( "image/x-gzeps" ) ] = app_gzip; // check we can read bzip2-compressed files f.reset( KCompressionDevice::filterForCompressionType( KCompressionDevice::BZip2 ) ); diff --git a/ui/guiutils.cpp b/ui/guiutils.cpp index 090792736..86d01eb81 100644 --- a/ui/guiutils.cpp +++ b/ui/guiutils.cpp @@ -35,7 +35,7 @@ struct GuiUtilsHelper QSvgRenderer* svgStamps(); QList il; - std::auto_ptr< QSvgRenderer > svgStampFile; + std::unique_ptr< QSvgRenderer > svgStampFile; }; QSvgRenderer* GuiUtilsHelper::svgStamps()