Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
delete contents in destructor and add missing mutexes
- Loading branch information
|
@@ -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. |
|
|