summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kundrát <jkt@kde.org>2015-04-09 01:37:24 (GMT)
committerJan Kundrát <jkt@kde.org>2015-07-20 14:14:01 (GMT)
commitabd30fb774f6d0cd5abf93019f652c0ca54778f4 (patch)
treeaf1bb6aab82dec5a214a1982871b1b60a7bc1dd5
parent5ecffc246b6e00441386cbd0c107a19432ffe3b9 (diff)
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
-rw-r--r--core/document.cpp8
-rw-r--r--generators/comicbook/directory.cpp2
-rw-r--r--generators/comicbook/unrar.cpp2
-rw-r--r--part.cpp2
-rw-r--r--ui/guiutils.cpp2
5 files changed, 8 insertions, 8 deletions
diff --git a/core/document.cpp b/core/document.cpp
index 34218f5..665844b 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 ec023b3..2604247 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<QFile> file( new QFile( path ) );
+ std::unique_ptr<QFile> file( new QFile( path ) );
if ( !file->open( QIODevice::ReadOnly ) )
return 0;
diff --git a/generators/comicbook/unrar.cpp b/generators/comicbook/unrar.cpp
index 731305f..1edabbe 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 05590e8..b650c9f 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 0907927..86d01eb 100644
--- a/ui/guiutils.cpp
+++ b/ui/guiutils.cpp
@@ -35,7 +35,7 @@ struct GuiUtilsHelper
QSvgRenderer* svgStamps();
QList<KIconLoader *> il;
- std::auto_ptr< QSvgRenderer > svgStampFile;
+ std::unique_ptr< QSvgRenderer > svgStampFile;
};
QSvgRenderer* GuiUtilsHelper::svgStamps()