Commit 711ea263 authored by Nicolas Fella's avatar Nicolas Fella
Browse files

[archive] Use unique_ptr to manage lifetime of QIODevice

That way we can't forget to delete it
parent eb5f0223
Pipeline #198045 passed with stage
in 5 minutes and 56 seconds
......@@ -26,6 +26,8 @@
#include <kuser.h>
#include <KLocalizedString>
#include <memory>
#ifdef Q_OS_WIN
#define S_ISDIR(m) (((m & S_IFMT) == S_IFDIR))
#endif
......@@ -495,7 +497,7 @@ void ArchiveProtocolBase::get( const QUrl & url )
* - errors are skipped, resulting in an empty file
*/
QIODevice* io = archiveFileEntry->createDevice();
std::unique_ptr<QIODevice> io(archiveFileEntry->createDevice());
if (!io)
{
......@@ -508,7 +510,6 @@ void ArchiveProtocolBase::get( const QUrl & url )
if ( !io->open( QIODevice::ReadOnly ) )
{
error( KIO::ERR_CANNOT_OPEN_FOR_READING, url.toDisplayString() );
delete io;
return;
}
......@@ -524,7 +525,6 @@ void ArchiveProtocolBase::get( const QUrl & url )
{
// Something went wrong
error( KIO::ERR_OUT_OF_MEMORY, url.toDisplayString() );
delete io;
return;
}
......@@ -546,7 +546,6 @@ void ArchiveProtocolBase::get( const QUrl & url )
{
qCWarning(KIO_ARCHIVE_LOG) << "Read" << read << "bytes but expected" << bufferSize ;
error( KIO::ERR_CANNOT_READ, url.toDisplayString() );
delete io;
return;
}
if ( firstRead )
......@@ -565,7 +564,6 @@ void ArchiveProtocolBase::get( const QUrl & url )
fileSize -= bufferSize;
}
io->close();
delete io;
data( QByteArray() );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment