Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit f7ec9df0 authored by Fabio D'Urso's avatar Fabio D'Urso

Don't leak temporary unpacked metadata files extracted from .okular files

parent 6bf6b14f
......@@ -109,7 +109,7 @@ struct ArchiveData
}
KTemporaryFile document;
QString metadataFileName;
KTemporaryFile metadataFile;
};
struct RunningSearch
......@@ -613,12 +613,12 @@ void DocumentPrivate::loadDocumentInfo()
if ( m_xmlFileName.isEmpty() )
return;
loadDocumentInfo( m_xmlFileName );
QFile infoFile( m_xmlFileName );
loadDocumentInfo( infoFile );
}
void DocumentPrivate::loadDocumentInfo( const QString &fileName )
void DocumentPrivate::loadDocumentInfo( QFile &infoFile )
{
QFile infoFile( fileName );
if ( !infoFile.exists() || !infoFile.open( QIODevice::ReadOnly ) )
return;
......@@ -2263,7 +2263,7 @@ bool Document::openDocument( const QString & docFile, const KUrl& url, const KMi
// 2. load Additional Data (bookmarks, local annotations and metadata) about the document
if ( d->m_archiveData )
{
d->loadDocumentInfo( d->m_archiveData->metadataFileName );
d->loadDocumentInfo( d->m_archiveData->metadataFile );
d->m_annotationsNeedSaveAs = true;
}
else
......@@ -4192,19 +4192,15 @@ bool Document::openDocumentArchive( const QString & docFile, const KUrl & url )
archiveData->document.close();
}
std::auto_ptr< KTemporaryFile > tempMetadataFileName;
const KArchiveEntry * metadataEntry = mainDir->entry( metadataFileName );
if ( metadataEntry && metadataEntry->isFile() )
{
std::auto_ptr< QIODevice > metadataEntryDevice( static_cast< const KZipFileEntry * >( metadataEntry )->createDevice() );
tempMetadataFileName.reset( new KTemporaryFile() );
tempMetadataFileName->setSuffix( ".xml" );
tempMetadataFileName->setAutoRemove( false );
if ( tempMetadataFileName->open() )
archiveData->metadataFile.setSuffix( ".xml" );
if ( archiveData->metadataFile.open() )
{
copyQIODevice( metadataEntryDevice.get(), tempMetadataFileName.get() );
archiveData->metadataFileName = tempMetadataFileName->fileName();
tempMetadataFileName->close();
copyQIODevice( metadataEntryDevice.get(), &archiveData->metadataFile );
archiveData->metadataFile.close();
}
}
......
......@@ -29,6 +29,7 @@
class QUndoStack;
class QEventLoop;
class QFile;
class QTimer;
class KTemporaryFile;
......@@ -121,7 +122,7 @@ class DocumentPrivate
qulonglong getTotalMemory();
qulonglong getFreeMemory( qulonglong *freeSwap = 0 );
void loadDocumentInfo();
void loadDocumentInfo( const QString &fileName );
void loadDocumentInfo( QFile &infoFile );
void loadViewsInfo( View *view, const QDomElement &e );
void saveViewsInfo( View *view, QDomElement &e ) const;
QString giveAbsolutePath( const QString & fileName ) const;
......
Markdown is supported
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