mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-19 00:04:52 -04:00
[Spatialite provider] Properly destroy QgsSpatiaLiteConnPool singleton at provider unloading. Should fix frequent crash in PyQgsServerWMS on Travis (fixes #17447)
This commit is contained in:
parent
7fa11c826f
commit
581d0d30ca
@ -13,11 +13,30 @@
|
|||||||
* *
|
* *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include <QMutex>
|
||||||
|
#include <QMutexLocker>
|
||||||
|
|
||||||
#include "qgsspatialiteconnpool.h"
|
#include "qgsspatialiteconnpool.h"
|
||||||
|
|
||||||
QgsSpatiaLiteConnPool QgsSpatiaLiteConnPool::sInstance;
|
QgsSpatiaLiteConnPool *QgsSpatiaLiteConnPool::sInstance = nullptr;
|
||||||
|
|
||||||
QgsSpatiaLiteConnPool *QgsSpatiaLiteConnPool::instance()
|
QgsSpatiaLiteConnPool *QgsSpatiaLiteConnPool::instance()
|
||||||
{
|
{
|
||||||
return &sInstance;
|
if ( ! sInstance )
|
||||||
|
{
|
||||||
|
static QMutex sMutex;
|
||||||
|
QMutexLocker locker( &sMutex );
|
||||||
|
if ( ! sInstance )
|
||||||
|
{
|
||||||
|
sInstance = new QgsSpatiaLiteConnPool();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
// static public
|
||||||
|
void QgsSpatiaLiteConnPool::cleanupInstance()
|
||||||
|
{
|
||||||
|
delete sInstance;
|
||||||
|
sInstance = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -68,9 +68,19 @@ class QgsSpatiaLiteConnPoolGroup : public QObject, public QgsConnectionPoolGroup
|
|||||||
//! SpatiaLite connection pool - singleton
|
//! SpatiaLite connection pool - singleton
|
||||||
class QgsSpatiaLiteConnPool : public QgsConnectionPool<QgsSqliteHandle *, QgsSpatiaLiteConnPoolGroup>
|
class QgsSpatiaLiteConnPool : public QgsConnectionPool<QgsSqliteHandle *, QgsSpatiaLiteConnPoolGroup>
|
||||||
{
|
{
|
||||||
static QgsSpatiaLiteConnPool sInstance;
|
static QgsSpatiaLiteConnPool *sInstance;
|
||||||
public:
|
public:
|
||||||
static QgsSpatiaLiteConnPool *instance();
|
static QgsSpatiaLiteConnPool *instance();
|
||||||
|
|
||||||
|
// Singleton cleanup
|
||||||
|
//
|
||||||
|
// Make sure nobody is using the instance before calling
|
||||||
|
// this function.
|
||||||
|
//
|
||||||
|
// WARNING: concurrent call from multiple threads may result
|
||||||
|
// in double-free of the instance.
|
||||||
|
//
|
||||||
|
static void cleanupInstance();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -5900,6 +5900,7 @@ QGISEXTERN QString getStyleById( const QString &uri, QString styleId, QString &e
|
|||||||
|
|
||||||
QGISEXTERN void cleanupProvider()
|
QGISEXTERN void cleanupProvider()
|
||||||
{
|
{
|
||||||
|
QgsSpatiaLiteConnPool::cleanupInstance();
|
||||||
QgsSqliteHandle::closeAll();
|
QgsSqliteHandle::closeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user