Skip to content
Permalink
Browse files

Fix crash on exit: Close all cached sqlite connections

  • Loading branch information
m-kuhn committed Nov 24, 2014
1 parent b6e8f01 commit 4e36059371dfe862b5904ed1c52e5428d20faf2f
@@ -800,6 +800,18 @@ void QgsSqliteHandle::closeDb( QgsSqliteHandle * &handle )
handle = NULL;
}

void QgsSqliteHandle::closeAll()
{
QMap < QString, QgsSqliteHandle * >::iterator i;
for ( i = handles.begin(); i != handles.end(); ++i )
{
i.value()->sqliteClose();
delete i.value();
}

handles.clear();
}

void QgsSqliteHandle::sqliteClose()
{
if ( sqlite_handle )
@@ -155,6 +155,12 @@ class QgsSqliteHandle
static QgsSqliteHandle *openDb( const QString & dbPath, bool shared = true );
static bool checkMetadata( sqlite3 * handle );
static void closeDb( QgsSqliteHandle * &handle );

/**
* Will close any cached connection
* To be called on application exit
*/
static void closeAll();
//static void closeDb( QMap < QString, QgsSqliteHandle * >&handlesRO, QgsSqliteHandle * &handle );

private:
@@ -5560,3 +5560,8 @@ QGISEXTERN QString getStyleById( const QString& uri, QString styleId, QString& e
sqlite3_free_table( results );
return style;
}

QGISEXTERN void cleanupProvider()
{
QgsSqliteHandle::closeAll();
}

0 comments on commit 4e36059

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