Skip to content
Permalink
Browse files

delete contents in destructor and add missing mutexes

  • Loading branch information
3nids committed May 7, 2018
1 parent 5610ebe commit b4d00d95a17ffabecd63301e27daea97e5dd4225
@@ -39,6 +39,8 @@ FetchedContent holds useful information about a network content being fetched
%Docstring
Constructs a FetchedContent with pointer to the downloaded file and status of the download
%End
~QgsFetchedContent();



const QString filePath() const;
@@ -30,8 +30,7 @@ QgsNetworkContentFetcherRegistry::~QgsNetworkContentFetcherRegistry()
QMap<QUrl, QgsFetchedContent *>::const_iterator it = mFileRegistry.constBegin();
for ( ; it != mFileRegistry.constEnd(); ++it )
{
it.value()->mFile->close();
delete it.value()->mFile;
delete it.value();
}
mFileRegistry.clear();
}
@@ -136,6 +135,7 @@ const QFile *QgsNetworkContentFetcherRegistry::localFile( const QString &filePat

if ( !QUrl::fromUserInput( filePathOrUrl ).isLocalFile() )
{
QMutexLocker locker( &mMutex );
if ( mFileRegistry.contains( QUrl( path ) ) )
{
const QgsFetchedContent *content = mFileRegistry.value( QUrl( path ) );
@@ -166,6 +166,7 @@ QString QgsNetworkContentFetcherRegistry::localPath( const QString &filePathOrUr

if ( !QUrl::fromUserInput( filePathOrUrl ).isLocalFile() )
{
QMutexLocker locker( &mMutex );
if ( mFileRegistry.contains( QUrl( path ) ) )
{
const QgsFetchedContent *content = mFileRegistry.value( QUrl( path ) );
@@ -57,6 +57,12 @@ class CORE_EXPORT QgsFetchedContent : public QObject
explicit QgsFetchedContent( QTemporaryFile *file = nullptr, ContentStatus status = NotStarted )
: QObject(), mFile( file ), mStatus( status ) {}

~QgsFetchedContent()
{
mFile->close();
delete mFile;
}


#ifndef SIP_RUN
//! Return a pointer to the local file, a null pointer if the file is not accessible yet.

0 comments on commit b4d00d9

Please sign in to comment.
You can’t perform that action at this time.