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
frameworks
Jan Kundrát 11 years ago
parent 5ecffc246b
commit abd30fb774
  1. 8
      core/document.cpp
  2. 2
      generators/comicbook/directory.cpp
  3. 2
      generators/comicbook/unrar.cpp
  4. 2
      part.cpp
  5. 2
      ui/guiutils.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() )
{

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

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

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

@ -35,7 +35,7 @@ struct GuiUtilsHelper
QSvgRenderer* svgStamps();
QList<KIconLoader *> il;
std::auto_ptr< QSvgRenderer > svgStampFile;
std::unique_ptr< QSvgRenderer > svgStampFile;
};
QSvgRenderer* GuiUtilsHelper::svgStamps()

Loading…
Cancel
Save