mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-10 00:04:23 -04:00
[qt6] Use RecursiveMutex instead of QMutex( QMutex::Recursive )
QMutex::Recursive will be gone. The replacement only entered the stage with Qt 5.14
This commit is contained in:
parent
f98ab57c1c
commit
e94d9bc024
@ -99,7 +99,7 @@ Required build tools:
|
|||||||
|
|
||||||
Required build dependencies:
|
Required build dependencies:
|
||||||
|
|
||||||
* Qt >= 5.9.0
|
* Qt >= 5.12.0
|
||||||
* Proj >= 4.9.3
|
* Proj >= 4.9.3
|
||||||
* GEOS >= 3.4
|
* GEOS >= 3.4
|
||||||
* Sqlite3 >= 3.0.0
|
* Sqlite3 >= 3.0.0
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class QgsAuthMethod : QObject
|
class QgsAuthMethod : QObject
|
||||||
{
|
{
|
||||||
%Docstring(signature="appended")
|
%Docstring(signature="appended")
|
||||||
@ -153,7 +154,6 @@ Construct a default authentication method
|
|||||||
Non-public since this is an abstract base class
|
Non-public since this is an abstract base class
|
||||||
%End
|
%End
|
||||||
|
|
||||||
|
|
||||||
static QString authMethodTag();
|
static QString authMethodTag();
|
||||||
%Docstring
|
%Docstring
|
||||||
Tag signifying that this is an authentcation method (e.g. for use as title in message log panel output)
|
Tag signifying that this is an authentcation method (e.g. for use as title in message log panel output)
|
||||||
@ -173,7 +173,6 @@ Sets the support expansions (points in providers where the authentication is inj
|
|||||||
Sets list of data providers this auth method supports
|
Sets list of data providers this auth method supports
|
||||||
%End
|
%End
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
QFlags<QgsAuthMethod::Expansion> operator|(QgsAuthMethod::Expansion f1, QFlags<QgsAuthMethod::Expansion> f2);
|
QFlags<QgsAuthMethod::Expansion> operator|(QgsAuthMethod::Expansion f1, QFlags<QgsAuthMethod::Expansion> f2);
|
||||||
|
|
||||||
|
@ -136,6 +136,7 @@ set(QGIS_CORE_SRCS
|
|||||||
auth/qgsauthconfig.cpp
|
auth/qgsauthconfig.cpp
|
||||||
auth/qgsauthcrypto.cpp
|
auth/qgsauthcrypto.cpp
|
||||||
auth/qgsauthmanager.cpp
|
auth/qgsauthmanager.cpp
|
||||||
|
auth/qgsauthmethod.cpp
|
||||||
auth/qgsauthmethodmetadata.cpp
|
auth/qgsauthmethodmetadata.cpp
|
||||||
auth/qgsauthmethodregistry.cpp
|
auth/qgsauthmethodregistry.cpp
|
||||||
|
|
||||||
|
@ -100,8 +100,13 @@ QgsAuthManager *QgsAuthManager::instance()
|
|||||||
|
|
||||||
QgsAuthManager::QgsAuthManager()
|
QgsAuthManager::QgsAuthManager()
|
||||||
{
|
{
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
mMutex.reset( new QMutex( QMutex::Recursive ) );
|
mMutex.reset( new QMutex( QMutex::Recursive ) );
|
||||||
mMasterPasswordMutex.reset( new QMutex( QMutex::Recursive ) );
|
mMasterPasswordMutex.reset( new QMutex( QMutex::Recursive ) );
|
||||||
|
#else
|
||||||
|
mMutex = std::make_unique<QRecursiveMutex>();
|
||||||
|
mMasterPasswordMutex = std::make_unique<QRecursiveMutex>();
|
||||||
|
#endif
|
||||||
connect( this, &QgsAuthManager::messageOut,
|
connect( this, &QgsAuthManager::messageOut,
|
||||||
this, &QgsAuthManager::writeToConsole );
|
this, &QgsAuthManager::writeToConsole );
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,11 @@
|
|||||||
#include "qgis_core.h"
|
#include "qgis_core.h"
|
||||||
#include "qgis_sip.h"
|
#include "qgis_sip.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
|
#else
|
||||||
|
#include <QRecursiveMutex>
|
||||||
|
#endif
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QSqlDatabase>
|
#include <QSqlDatabase>
|
||||||
@ -870,9 +874,13 @@ class CORE_EXPORT QgsAuthManager : public QObject
|
|||||||
bool mScheduledDbEraseRequestEmitted = false;
|
bool mScheduledDbEraseRequestEmitted = false;
|
||||||
int mScheduledDbEraseRequestCount = 0;
|
int mScheduledDbEraseRequestCount = 0;
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
std::unique_ptr<QMutex> mMutex;
|
std::unique_ptr<QMutex> mMutex;
|
||||||
std::unique_ptr<QMutex> mMasterPasswordMutex;
|
std::unique_ptr<QMutex> mMasterPasswordMutex;
|
||||||
|
#else
|
||||||
|
std::unique_ptr<QRecursiveMutex> mMutex;
|
||||||
|
std::unique_ptr<QRecursiveMutex> mMasterPasswordMutex;
|
||||||
|
#endif
|
||||||
#ifndef QT_NO_SSL
|
#ifndef QT_NO_SSL
|
||||||
// mapping of sha1 digest and cert source and cert
|
// mapping of sha1 digest and cert source and cert
|
||||||
// appending removes duplicates
|
// appending removes duplicates
|
||||||
|
23
src/core/auth/qgsauthmethod.cpp
Normal file
23
src/core/auth/qgsauthmethod.cpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
qgsauthmethod.cpp
|
||||||
|
---------------------
|
||||||
|
begin : March 2021
|
||||||
|
copyright : (C) 2021
|
||||||
|
author : Matthias Khn
|
||||||
|
email : matthias@opengis.ch
|
||||||
|
***************************************************************************
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "qgsauthmethod.h"
|
||||||
|
|
||||||
|
QgsAuthMethod::QgsAuthMethod()
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
|
: mMutex( QMutex::RecursionMode::Recursive )
|
||||||
|
#endif
|
||||||
|
{}
|
@ -23,7 +23,12 @@
|
|||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
|
#else
|
||||||
|
#include <QRecursiveMutex>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include "qgis_core.h"
|
#include "qgis_core.h"
|
||||||
|
|
||||||
@ -172,10 +177,7 @@ class CORE_EXPORT QgsAuthMethod : public QObject
|
|||||||
* Construct a default authentication method
|
* Construct a default authentication method
|
||||||
* \note Non-public since this is an abstract base class
|
* \note Non-public since this is an abstract base class
|
||||||
*/
|
*/
|
||||||
explicit QgsAuthMethod()
|
explicit QgsAuthMethod();
|
||||||
: mMutex( QMutex::RecursionMode::Recursive )
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
//! Tag signifying that this is an authentcation method (e.g. for use as title in message log panel output)
|
//! Tag signifying that this is an authentcation method (e.g. for use as title in message log panel output)
|
||||||
static QString authMethodTag() { return QObject::tr( "Authentication method" ); }
|
static QString authMethodTag() { return QObject::tr( "Authentication method" ); }
|
||||||
@ -191,8 +193,11 @@ class CORE_EXPORT QgsAuthMethod : public QObject
|
|||||||
QgsAuthMethod::Expansions mExpansions = QgsAuthMethod::Expansions();
|
QgsAuthMethod::Expansions mExpansions = QgsAuthMethod::Expansions();
|
||||||
QStringList mDataProviders;
|
QStringList mDataProviders;
|
||||||
int mVersion = 0;
|
int mVersion = 0;
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
QMutex mMutex;
|
QMutex mMutex;
|
||||||
|
#else
|
||||||
|
QRecursiveMutex mMutex;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsAuthMethod::Expansions )
|
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsAuthMethod::Expansions )
|
||||||
|
|
||||||
|
@ -6328,8 +6328,13 @@ const QList<QgsExpressionFunction *> &QgsExpression::Functions()
|
|||||||
// crashes in the WFS provider may occur, since it can parse expressions
|
// crashes in the WFS provider may occur, since it can parse expressions
|
||||||
// in parallel.
|
// in parallel.
|
||||||
// The mutex needs to be recursive.
|
// The mutex needs to be recursive.
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
static QMutex sFunctionsMutex( QMutex::Recursive );
|
static QMutex sFunctionsMutex( QMutex::Recursive );
|
||||||
QMutexLocker locker( &sFunctionsMutex );
|
QMutexLocker locker( &sFunctionsMutex );
|
||||||
|
#else
|
||||||
|
static QRecursiveMutex sFunctionsMutex;
|
||||||
|
QMutexLocker locker( &sFunctionsMutex );
|
||||||
|
#endif
|
||||||
|
|
||||||
QList<QgsExpressionFunction *> &functions = *sFunctions();
|
QList<QgsExpressionFunction *> &functions = *sFunctions();
|
||||||
|
|
||||||
|
@ -71,7 +71,11 @@
|
|||||||
#define PROVIDER_DESCRIPTION QStringLiteral( "GDAL data provider" )
|
#define PROVIDER_DESCRIPTION QStringLiteral( "GDAL data provider" )
|
||||||
|
|
||||||
// To avoid potential races when destroying related instances ("main" and clones)
|
// To avoid potential races when destroying related instances ("main" and clones)
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
Q_GLOBAL_STATIC_WITH_ARGS( QMutex, sGdalProviderMutex, ( QMutex::Recursive ) )
|
Q_GLOBAL_STATIC_WITH_ARGS( QMutex, sGdalProviderMutex, ( QMutex::Recursive ) )
|
||||||
|
#else
|
||||||
|
Q_GLOBAL_STATIC( QRecursiveMutex, sGdalProviderMutex )
|
||||||
|
#endif
|
||||||
|
|
||||||
QHash< QgsGdalProvider *, QVector<QgsGdalProvider::DatasetPair> > QgsGdalProvider::mgDatasetCache;
|
QHash< QgsGdalProvider *, QVector<QgsGdalProvider::DatasetPair> > QgsGdalProvider::mgDatasetCache;
|
||||||
|
|
||||||
@ -146,7 +150,11 @@ QgsGdalProvider::QgsGdalProvider( const QString &uri, const QgsError &error )
|
|||||||
QgsGdalProvider::QgsGdalProvider( const QString &uri, const ProviderOptions &options, bool update, GDALDatasetH dataset )
|
QgsGdalProvider::QgsGdalProvider( const QString &uri, const ProviderOptions &options, bool update, GDALDatasetH dataset )
|
||||||
: QgsRasterDataProvider( uri, options )
|
: QgsRasterDataProvider( uri, options )
|
||||||
, mpRefCounter( new QAtomicInt( 1 ) )
|
, mpRefCounter( new QAtomicInt( 1 ) )
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
, mpMutex( new QMutex( QMutex::Recursive ) )
|
, mpMutex( new QMutex( QMutex::Recursive ) )
|
||||||
|
#else
|
||||||
|
, mpMutex( new QRecursiveMutex() )
|
||||||
|
#endif
|
||||||
, mpParent( new QgsGdalProvider * ( this ) )
|
, mpParent( new QgsGdalProvider * ( this ) )
|
||||||
, mpLightRefCounter( new QAtomicInt( 1 ) )
|
, mpLightRefCounter( new QAtomicInt( 1 ) )
|
||||||
, mUpdate( update )
|
, mUpdate( update )
|
||||||
@ -238,7 +246,12 @@ QgsGdalProvider::QgsGdalProvider( const QgsGdalProvider &other )
|
|||||||
|
|
||||||
mpRefCounter = new QAtomicInt( 1 );
|
mpRefCounter = new QAtomicInt( 1 );
|
||||||
mpLightRefCounter = other.mpLightRefCounter;
|
mpLightRefCounter = other.mpLightRefCounter;
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
mpMutex = new QMutex( QMutex::Recursive );
|
mpMutex = new QMutex( QMutex::Recursive );
|
||||||
|
#else
|
||||||
|
mpMutex = new QRecursiveMutex();
|
||||||
|
#endif
|
||||||
|
|
||||||
mpParent = other.mpParent;
|
mpParent = other.mpParent;
|
||||||
|
|
||||||
if ( getCachedGdalHandles( const_cast<QgsGdalProvider *>( &other ), mGdalBaseDataset, mGdalDataset ) )
|
if ( getCachedGdalHandles( const_cast<QgsGdalProvider *>( &other ), mGdalBaseDataset, mGdalDataset ) )
|
||||||
|
@ -235,7 +235,12 @@ class QgsGdalProvider final: public QgsRasterDataProvider, QgsGdalProviderBase
|
|||||||
QAtomicInt *mpRefCounter = nullptr;
|
QAtomicInt *mpRefCounter = nullptr;
|
||||||
|
|
||||||
// mutex to protect access to mGdalDataset among main and shared provider instances
|
// mutex to protect access to mGdalDataset among main and shared provider instances
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
QMutex *mpMutex = nullptr;
|
QMutex *mpMutex = nullptr;
|
||||||
|
#else
|
||||||
|
QRecursiveMutex *mpMutex = nullptr;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// pointer to a QgsGdalProvider* that is the parent. Note when *mpParent == this, we are the parent.
|
// pointer to a QgsGdalProvider* that is the parent. Note when *mpParent == this, we are the parent.
|
||||||
QgsGdalProvider **mpParent = nullptr;
|
QgsGdalProvider **mpParent = nullptr;
|
||||||
|
@ -99,7 +99,12 @@ static OGRwkbGeometryType ogrWkbGeometryTypeFromName( const QString &typeName );
|
|||||||
|
|
||||||
static bool IsLocalFile( const QString &path );
|
static bool IsLocalFile( const QString &path );
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
Q_GLOBAL_STATIC_WITH_ARGS( QMutex, sGlobalMutex, ( QMutex::Recursive ) )
|
Q_GLOBAL_STATIC_WITH_ARGS( QMutex, sGlobalMutex, ( QMutex::Recursive ) )
|
||||||
|
#else
|
||||||
|
Q_GLOBAL_STATIC( QRecursiveMutex, sGlobalMutex )
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//! Map a dataset name to the number of opened GDAL dataset objects on it (if opened with GDALOpenWrapper, only for GPKG)
|
//! Map a dataset name to the number of opened GDAL dataset objects on it (if opened with GDALOpenWrapper, only for GPKG)
|
||||||
typedef QMap< QString, int > OpenedDsCountMap;
|
typedef QMap< QString, int > OpenedDsCountMap;
|
||||||
@ -603,7 +608,11 @@ QgsOgrProvider::QgsOgrProvider( QString const &uri, const ProviderOptions &optio
|
|||||||
mLayerMetadata.setType( QStringLiteral( "dataset" ) );
|
mLayerMetadata.setType( QStringLiteral( "dataset" ) );
|
||||||
if ( mOgrOrigLayer )
|
if ( mOgrOrigLayer )
|
||||||
{
|
{
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
QMutex *mutex = nullptr;
|
QMutex *mutex = nullptr;
|
||||||
|
#else
|
||||||
|
QRecursiveMutex *mutex = nullptr;
|
||||||
|
#endif
|
||||||
OGRLayerH layer = mOgrOrigLayer->getHandleAndMutex( mutex );
|
OGRLayerH layer = mOgrOrigLayer->getHandleAndMutex( mutex );
|
||||||
QMutexLocker locker( mutex );
|
QMutexLocker locker( mutex );
|
||||||
const QString identifier = GDALGetMetadataItem( layer, "IDENTIFIER", nullptr );
|
const QString identifier = GDALGetMetadataItem( layer, "IDENTIFIER", nullptr );
|
||||||
@ -1104,7 +1113,11 @@ void QgsOgrProvider::loadFields()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
QMutex *mutex = nullptr;
|
QMutex *mutex = nullptr;
|
||||||
|
#else
|
||||||
|
QRecursiveMutex *mutex = nullptr;
|
||||||
|
#endif
|
||||||
OGRLayerH ogrLayer = mOgrLayer->getHandleAndMutex( mutex );
|
OGRLayerH ogrLayer = mOgrLayer->getHandleAndMutex( mutex );
|
||||||
QMutexLocker locker( mutex );
|
QMutexLocker locker( mutex );
|
||||||
mOGRGeomType = getOgrGeomType( mGDALDriverName, ogrLayer );
|
mOGRGeomType = getOgrGeomType( mGDALDriverName, ogrLayer );
|
||||||
@ -1314,7 +1327,11 @@ QString QgsOgrProvider::storageType() const
|
|||||||
|
|
||||||
void QgsOgrProvider::setRelevantFields( bool fetchGeometry, const QgsAttributeList &fetchAttributes ) const
|
void QgsOgrProvider::setRelevantFields( bool fetchGeometry, const QgsAttributeList &fetchAttributes ) const
|
||||||
{
|
{
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
QMutex *mutex = nullptr;
|
QMutex *mutex = nullptr;
|
||||||
|
#else
|
||||||
|
QRecursiveMutex *mutex = nullptr;
|
||||||
|
#endif
|
||||||
OGRLayerH ogrLayer = mOgrLayer->getHandleAndMutex( mutex );
|
OGRLayerH ogrLayer = mOgrLayer->getHandleAndMutex( mutex );
|
||||||
QMutexLocker locker( mutex );
|
QMutexLocker locker( mutex );
|
||||||
QgsOgrProviderUtils::setRelevantFields( ogrLayer, mAttributeFields.count(), fetchGeometry, fetchAttributes, mFirstFieldIsFid, mSubsetString );
|
QgsOgrProviderUtils::setRelevantFields( ogrLayer, mAttributeFields.count(), fetchGeometry, fetchAttributes, mFirstFieldIsFid, mSubsetString );
|
||||||
@ -1904,7 +1921,11 @@ bool QgsOgrProvider::addFeatures( QgsFeatureList &flist, Flags flags )
|
|||||||
if ( !( flags & QgsFeatureSink::FastInsert ) &&
|
if ( !( flags & QgsFeatureSink::FastInsert ) &&
|
||||||
( mGDALDriverName == QLatin1String( "CSV" ) || mGDALDriverName == QLatin1String( "XLSX" ) || mGDALDriverName == QLatin1String( "ODS" ) ) )
|
( mGDALDriverName == QLatin1String( "CSV" ) || mGDALDriverName == QLatin1String( "XLSX" ) || mGDALDriverName == QLatin1String( "ODS" ) ) )
|
||||||
{
|
{
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
QMutex *mutex = nullptr;
|
QMutex *mutex = nullptr;
|
||||||
|
#else
|
||||||
|
QRecursiveMutex *mutex = nullptr;
|
||||||
|
#endif
|
||||||
OGRLayerH layer = mOgrOrigLayer->getHandleAndMutex( mutex );
|
OGRLayerH layer = mOgrOrigLayer->getHandleAndMutex( mutex );
|
||||||
{
|
{
|
||||||
QMutexLocker locker( mutex );
|
QMutexLocker locker( mutex );
|
||||||
@ -2277,7 +2298,11 @@ bool QgsOgrProvider::_setSubsetString( const QString &theSQL, bool updateFeature
|
|||||||
|
|
||||||
if ( !theSQL.isEmpty() )
|
if ( !theSQL.isEmpty() )
|
||||||
{
|
{
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
QMutex *mutex = nullptr;
|
QMutex *mutex = nullptr;
|
||||||
|
#else
|
||||||
|
QRecursiveMutex *mutex = nullptr;
|
||||||
|
#endif
|
||||||
OGRLayerH layer = mOgrOrigLayer->getHandleAndMutex( mutex );
|
OGRLayerH layer = mOgrOrigLayer->getHandleAndMutex( mutex );
|
||||||
GDALDatasetH ds = mOgrOrigLayer->getDatasetHandleAndMutex( mutex );
|
GDALDatasetH ds = mOgrOrigLayer->getDatasetHandleAndMutex( mutex );
|
||||||
OGRLayerH subsetLayerH;
|
OGRLayerH subsetLayerH;
|
||||||
@ -2306,7 +2331,11 @@ bool QgsOgrProvider::_setSubsetString( const QString &theSQL, bool updateFeature
|
|||||||
{
|
{
|
||||||
mOgrSqlLayer.reset();
|
mOgrSqlLayer.reset();
|
||||||
mOgrLayer = mOgrOrigLayer.get();
|
mOgrLayer = mOgrOrigLayer.get();
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
QMutex *mutex = nullptr;
|
QMutex *mutex = nullptr;
|
||||||
|
#else
|
||||||
|
QRecursiveMutex *mutex = nullptr;
|
||||||
|
#endif
|
||||||
OGRLayerH layer = mOgrOrigLayer->getHandleAndMutex( mutex );
|
OGRLayerH layer = mOgrOrigLayer->getHandleAndMutex( mutex );
|
||||||
{
|
{
|
||||||
QMutexLocker locker( mutex );
|
QMutexLocker locker( mutex );
|
||||||
@ -2717,7 +2746,11 @@ bool QgsOgrProvider::createSpatialIndex()
|
|||||||
else if ( mGDALDriverName == QLatin1String( "GPKG" ) ||
|
else if ( mGDALDriverName == QLatin1String( "GPKG" ) ||
|
||||||
mGDALDriverName == QLatin1String( "SQLite" ) )
|
mGDALDriverName == QLatin1String( "SQLite" ) )
|
||||||
{
|
{
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
QMutex *mutex = nullptr;
|
QMutex *mutex = nullptr;
|
||||||
|
#else
|
||||||
|
QRecursiveMutex *mutex = nullptr;
|
||||||
|
#endif
|
||||||
OGRLayerH layer = mOgrOrigLayer->getHandleAndMutex( mutex );
|
OGRLayerH layer = mOgrOrigLayer->getHandleAndMutex( mutex );
|
||||||
QByteArray sql = QByteArray( "SELECT CreateSpatialIndex(" + quotedIdentifier( layerName ) + ","
|
QByteArray sql = QByteArray( "SELECT CreateSpatialIndex(" + quotedIdentifier( layerName ) + ","
|
||||||
+ quotedIdentifier( OGR_L_GetGeometryColumn( layer ) ) + ") " ); // quote the layer name so spaces are handled
|
+ quotedIdentifier( OGR_L_GetGeometryColumn( layer ) ) + ") " ); // quote the layer name so spaces are handled
|
||||||
@ -6205,13 +6238,21 @@ void QgsOgrLayer::SetSpatialFilter( OGRGeometryH hGeometry )
|
|||||||
OGR_L_SetSpatialFilter( hLayer, hGeometry );
|
OGR_L_SetSpatialFilter( hLayer, hGeometry );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
GDALDatasetH QgsOgrLayer::getDatasetHandleAndMutex( QMutex *&mutex )
|
GDALDatasetH QgsOgrLayer::getDatasetHandleAndMutex( QMutex *&mutex )
|
||||||
|
#else
|
||||||
|
GDALDatasetH QgsOgrLayer::getDatasetHandleAndMutex( QRecursiveMutex *&mutex )
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
mutex = &( ds->mutex );
|
mutex = &( ds->mutex );
|
||||||
return ds->hDS;
|
return ds->hDS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
OGRLayerH QgsOgrLayer::getHandleAndMutex( QMutex *&mutex )
|
OGRLayerH QgsOgrLayer::getHandleAndMutex( QMutex *&mutex )
|
||||||
|
#else
|
||||||
|
OGRLayerH QgsOgrLayer::getHandleAndMutex( QRecursiveMutex *&mutex )
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
mutex = &( ds->mutex );
|
mutex = &( ds->mutex );
|
||||||
return hLayer;
|
return hLayer;
|
||||||
@ -6334,7 +6375,11 @@ QString QgsOgrLayer::GetMetadataItem( const QString &key, const QString &domain
|
|||||||
domain.toUtf8().constData() );
|
domain.toUtf8().constData() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
QMutex &QgsOgrFeatureDefn::mutex()
|
QMutex &QgsOgrFeatureDefn::mutex()
|
||||||
|
#else
|
||||||
|
QRecursiveMutex &QgsOgrFeatureDefn::mutex()
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
return layer->mutex();
|
return layer->mutex();
|
||||||
}
|
}
|
||||||
@ -6432,7 +6477,11 @@ bool QgsOgrProviderMetadata::saveStyle(
|
|||||||
if ( !userLayer )
|
if ( !userLayer )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
QMutex *mutex = nullptr;
|
QMutex *mutex = nullptr;
|
||||||
|
#else
|
||||||
|
QRecursiveMutex *mutex = nullptr;
|
||||||
|
#endif
|
||||||
OGRLayerH hUserLayer = userLayer->getHandleAndMutex( mutex );
|
OGRLayerH hUserLayer = userLayer->getHandleAndMutex( mutex );
|
||||||
GDALDatasetH hDS = userLayer->getDatasetHandleAndMutex( mutex );
|
GDALDatasetH hDS = userLayer->getDatasetHandleAndMutex( mutex );
|
||||||
QMutexLocker locker( mutex );
|
QMutexLocker locker( mutex );
|
||||||
@ -6644,7 +6693,11 @@ bool QgsOgrProviderMetadata::deleteStyleById( const QString &uri, QString styleI
|
|||||||
if ( !userLayer )
|
if ( !userLayer )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
QMutex *mutex = nullptr;
|
QMutex *mutex = nullptr;
|
||||||
|
#else
|
||||||
|
QRecursiveMutex *mutex = nullptr;
|
||||||
|
#endif
|
||||||
GDALDatasetH hDS = userLayer->getDatasetHandleAndMutex( mutex );
|
GDALDatasetH hDS = userLayer->getDatasetHandleAndMutex( mutex );
|
||||||
QMutexLocker locker( mutex );
|
QMutexLocker locker( mutex );
|
||||||
|
|
||||||
@ -6725,9 +6778,14 @@ QString QgsOgrProviderMetadata::loadStyle( const QString &uri, QString &errCause
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
QMutex *mutex1 = nullptr;
|
QMutex *mutex1 = nullptr;
|
||||||
OGRLayerH hLayer = layerStyles->getHandleAndMutex( mutex1 );
|
|
||||||
QMutex *mutex2 = nullptr;
|
QMutex *mutex2 = nullptr;
|
||||||
|
#else
|
||||||
|
QRecursiveMutex *mutex1 = nullptr;
|
||||||
|
QRecursiveMutex *mutex2 = nullptr;
|
||||||
|
#endif
|
||||||
|
OGRLayerH hLayer = layerStyles->getHandleAndMutex( mutex1 );
|
||||||
OGRLayerH hUserLayer = userLayer->getHandleAndMutex( mutex2 );
|
OGRLayerH hUserLayer = userLayer->getHandleAndMutex( mutex2 );
|
||||||
QMutexLocker lock1( mutex1 );
|
QMutexLocker lock1( mutex1 );
|
||||||
QMutexLocker lock2( mutex2 );
|
QMutexLocker lock2( mutex2 );
|
||||||
@ -6814,10 +6872,16 @@ int QgsOgrProviderMetadata::listStyles(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
QMutex *mutex1 = nullptr;
|
QMutex *mutex1 = nullptr;
|
||||||
|
QMutex *mutex2 = nullptr;
|
||||||
|
#else
|
||||||
|
QRecursiveMutex *mutex1 = nullptr;
|
||||||
|
QRecursiveMutex *mutex2 = nullptr;
|
||||||
|
#endif
|
||||||
|
|
||||||
OGRLayerH hLayer = layerStyles->getHandleAndMutex( mutex1 );
|
OGRLayerH hLayer = layerStyles->getHandleAndMutex( mutex1 );
|
||||||
QMutexLocker lock1( mutex1 );
|
QMutexLocker lock1( mutex1 );
|
||||||
QMutex *mutex2 = nullptr;
|
|
||||||
OGRLayerH hUserLayer = userLayer->getHandleAndMutex( mutex2 );
|
OGRLayerH hUserLayer = userLayer->getHandleAndMutex( mutex2 );
|
||||||
QMutexLocker lock2( mutex2 );
|
QMutexLocker lock2( mutex2 );
|
||||||
|
|
||||||
@ -6908,7 +6972,12 @@ QString QgsOgrProviderMetadata::getStyleById( const QString &uri, QString styleI
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
QMutex *mutex1 = nullptr;
|
QMutex *mutex1 = nullptr;
|
||||||
|
#else
|
||||||
|
QRecursiveMutex *mutex1 = nullptr;
|
||||||
|
#endif
|
||||||
|
|
||||||
OGRLayerH hLayer = layerStyles->getHandleAndMutex( mutex1 );
|
OGRLayerH hLayer = layerStyles->getHandleAndMutex( mutex1 );
|
||||||
QMutexLocker lock1( mutex1 );
|
QMutexLocker lock1( mutex1 );
|
||||||
|
|
||||||
|
@ -397,13 +397,21 @@ class CORE_EXPORT QgsOgrProviderUtils
|
|||||||
class DatasetWithLayers
|
class DatasetWithLayers
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
QMutex mutex;
|
QMutex mutex;
|
||||||
|
#else
|
||||||
|
QRecursiveMutex mutex;
|
||||||
|
#endif
|
||||||
GDALDatasetH hDS = nullptr;
|
GDALDatasetH hDS = nullptr;
|
||||||
QMap<QString, QgsOgrLayer *> setLayers;
|
QMap<QString, QgsOgrLayer *> setLayers;
|
||||||
int refCount = 0;
|
int refCount = 0;
|
||||||
bool canBeShared = true;
|
bool canBeShared = true;
|
||||||
|
|
||||||
DatasetWithLayers(): mutex( QMutex::Recursive ) {}
|
DatasetWithLayers()
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
|
: mutex( QMutex::Recursive )
|
||||||
|
#endif
|
||||||
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Map dataset identification to a list of corresponding DatasetWithLayers*
|
//! Map dataset identification to a list of corresponding DatasetWithLayers*
|
||||||
@ -559,8 +567,11 @@ class QgsOgrDataset
|
|||||||
|
|
||||||
static QgsOgrDatasetSharedPtr create( const QgsOgrProviderUtils::DatasetIdentification &ident,
|
static QgsOgrDatasetSharedPtr create( const QgsOgrProviderUtils::DatasetIdentification &ident,
|
||||||
QgsOgrProviderUtils::DatasetWithLayers *ds );
|
QgsOgrProviderUtils::DatasetWithLayers *ds );
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
QMutex &mutex() { return mDs->mutex; }
|
QMutex &mutex() { return mDs->mutex; }
|
||||||
|
#else
|
||||||
|
QRecursiveMutex &mutex() { return mDs->mutex; }
|
||||||
|
#endif
|
||||||
|
|
||||||
bool executeSQLNoReturn( const QString &sql );
|
bool executeSQLNoReturn( const QString &sql );
|
||||||
|
|
||||||
@ -585,7 +596,11 @@ class QgsOgrFeatureDefn
|
|||||||
~QgsOgrFeatureDefn() = default;
|
~QgsOgrFeatureDefn() = default;
|
||||||
|
|
||||||
OGRFeatureDefnH get();
|
OGRFeatureDefnH get();
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
QMutex &mutex();
|
QMutex &mutex();
|
||||||
|
#else
|
||||||
|
QRecursiveMutex &mutex();
|
||||||
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -644,7 +659,11 @@ class QgsOgrLayer
|
|||||||
QgsOgrProviderUtils::DatasetWithLayers *ds,
|
QgsOgrProviderUtils::DatasetWithLayers *ds,
|
||||||
OGRLayerH hLayer );
|
OGRLayerH hLayer );
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
QMutex &mutex() { return ds->mutex; }
|
QMutex &mutex() { return ds->mutex; }
|
||||||
|
#else
|
||||||
|
QRecursiveMutex &mutex() { return ds->mutex; }
|
||||||
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -735,11 +754,20 @@ class QgsOgrLayer
|
|||||||
//! Wrapper of OGR_L_GetLayerCount
|
//! Wrapper of OGR_L_GetLayerCount
|
||||||
void SetSpatialFilter( OGRGeometryH );
|
void SetSpatialFilter( OGRGeometryH );
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
//! Returns native GDALDatasetH object with the mutex to lock when using it
|
//! Returns native GDALDatasetH object with the mutex to lock when using it
|
||||||
GDALDatasetH getDatasetHandleAndMutex( QMutex *&mutex );
|
GDALDatasetH getDatasetHandleAndMutex( QMutex *&mutex );
|
||||||
|
|
||||||
//! Returns native OGRLayerH object with the mutex to lock when using it
|
//! Returns native OGRLayerH object with the mutex to lock when using it
|
||||||
OGRLayerH getHandleAndMutex( QMutex *&mutex );
|
OGRLayerH getHandleAndMutex( QMutex *&mutex );
|
||||||
|
#else
|
||||||
|
//! Returns native GDALDatasetH object with the mutex to lock when using it
|
||||||
|
GDALDatasetH getDatasetHandleAndMutex( QRecursiveMutex *&mutex );
|
||||||
|
|
||||||
|
//! Returns native OGRLayerH object with the mutex to lock when using it
|
||||||
|
OGRLayerH getHandleAndMutex( QRecursiveMutex *&mutex );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//! Wrapper of GDALDatasetReleaseResultSet( GDALDatasetExecuteSQL( ... ) )
|
//! Wrapper of GDALDatasetReleaseResultSet( GDALDatasetExecuteSQL( ... ) )
|
||||||
void ExecuteSQLNoReturn( const QByteArray &sql );
|
void ExecuteSQLNoReturn( const QByteArray &sql );
|
||||||
|
@ -27,7 +27,11 @@
|
|||||||
#include "qgsnetworkcontentfetchertask.h"
|
#include "qgsnetworkcontentfetchertask.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
|
#else
|
||||||
|
#include <QRecursiveMutex>
|
||||||
|
#endif
|
||||||
#include <QCache>
|
#include <QCache>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
@ -210,7 +214,9 @@ class CORE_EXPORT QgsAbstractContentCache : public QgsAbstractContentCacheBase
|
|||||||
long maxCacheSize = 20000000,
|
long maxCacheSize = 20000000,
|
||||||
int fileModifiedCheckTimeout = 30000 )
|
int fileModifiedCheckTimeout = 30000 )
|
||||||
: QgsAbstractContentCacheBase( parent )
|
: QgsAbstractContentCacheBase( parent )
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
, mMutex( QMutex::Recursive )
|
, mMutex( QMutex::Recursive )
|
||||||
|
#endif
|
||||||
, mMaxCacheSize( maxCacheSize )
|
, mMaxCacheSize( maxCacheSize )
|
||||||
, mFileModifiedCheckTimeout( fileModifiedCheckTimeout )
|
, mFileModifiedCheckTimeout( fileModifiedCheckTimeout )
|
||||||
, mTypeString( typeString.isEmpty() ? QObject::tr( "Content" ) : typeString )
|
, mTypeString( typeString.isEmpty() ? QObject::tr( "Content" ) : typeString )
|
||||||
@ -548,8 +554,11 @@ class CORE_EXPORT QgsAbstractContentCache : public QgsAbstractContentCacheBase
|
|||||||
|
|
||||||
return currentEntry;
|
return currentEntry;
|
||||||
}
|
}
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
mutable QMutex mMutex;
|
mutable QMutex mMutex;
|
||||||
|
#else
|
||||||
|
mutable QRecursiveMutex mMutex;
|
||||||
|
#endif
|
||||||
//! Estimated total size of all cached content
|
//! Estimated total size of all cached content
|
||||||
long mTotalSize = 0;
|
long mTotalSize = 0;
|
||||||
|
|
||||||
|
@ -102,6 +102,9 @@
|
|||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||||
|
#include <QRecursiveMutex>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef Q_OS_WIN
|
#ifndef Q_OS_WIN
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
@ -2570,7 +2573,11 @@ QgsApplication::ApplicationMembers *QgsApplication::members()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
static QMutex sMemberMutex( QMutex::Recursive );
|
static QMutex sMemberMutex( QMutex::Recursive );
|
||||||
|
#else
|
||||||
|
static QRecursiveMutex sMemberMutex;
|
||||||
|
#endif
|
||||||
QMutexLocker lock( &sMemberMutex );
|
QMutexLocker lock( &sMemberMutex );
|
||||||
if ( !sApplicationMembers )
|
if ( !sApplicationMembers )
|
||||||
sApplicationMembers = new ApplicationMembers();
|
sApplicationMembers = new ApplicationMembers();
|
||||||
|
@ -389,7 +389,11 @@ class QgsTaskRunnableWrapper : public QRunnable
|
|||||||
|
|
||||||
QgsTaskManager::QgsTaskManager( QObject *parent )
|
QgsTaskManager::QgsTaskManager( QObject *parent )
|
||||||
: QObject( parent )
|
: QObject( parent )
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
, mTaskMutex( new QMutex( QMutex::Recursive ) )
|
, mTaskMutex( new QMutex( QMutex::Recursive ) )
|
||||||
|
#else
|
||||||
|
, mTaskMutex( new QRecursiveMutex() )
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -597,7 +597,11 @@ class CORE_EXPORT QgsTaskManager : public QObject
|
|||||||
|
|
||||||
bool mInitialized = false;
|
bool mInitialized = false;
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
mutable QMutex *mTaskMutex;
|
mutable QMutex *mTaskMutex;
|
||||||
|
#else
|
||||||
|
mutable QRecursiveMutex *mTaskMutex;
|
||||||
|
#endif
|
||||||
|
|
||||||
QMap< long, TaskInfo > mTasks;
|
QMap< long, TaskInfo > mTasks;
|
||||||
QMap< long, QgsTaskList > mTaskDependencies;
|
QMap< long, QgsTaskList > mTaskDependencies;
|
||||||
|
@ -144,7 +144,9 @@ void QgsTileDownloadManagerReplyWorkerObject::replyFinished()
|
|||||||
|
|
||||||
|
|
||||||
QgsTileDownloadManager::QgsTileDownloadManager()
|
QgsTileDownloadManager::QgsTileDownloadManager()
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
: mMutex( QMutex::Recursive )
|
: mMutex( QMutex::Recursive )
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,7 +281,11 @@ class CORE_EXPORT QgsTileDownloadManager
|
|||||||
|
|
||||||
QList<QueueEntry> mQueue;
|
QList<QueueEntry> mQueue;
|
||||||
bool mShuttingDown = false;
|
bool mShuttingDown = false;
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
mutable QMutex mMutex;
|
mutable QMutex mMutex;
|
||||||
|
#else
|
||||||
|
mutable QRecursiveMutex mMutex;
|
||||||
|
#endif
|
||||||
QThread *mWorkerThread = nullptr;
|
QThread *mWorkerThread = nullptr;
|
||||||
QgsTileDownloadManagerWorker *mWorker = nullptr;
|
QgsTileDownloadManagerWorker *mWorker = nullptr;
|
||||||
Stats mStats;
|
Stats mStats;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user