-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adopt 'new' spatialite initialization scheme via thin wrapper around …
…sqlite3_open and sqlite3_close (fixes #12771) (cherry picked from commit 252aaab, 23ef9da, d4b72a2, c7cb963 and e255d6c)
- Loading branch information
Showing
17 changed files
with
213 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/*************************************************************************** | ||
qgsslconnect.cpp - thin wrapper class to connect to spatialite databases | ||
---------------------- | ||
begin : May 2015 | ||
copyright : (C) 2015 by Jürgen fischer | ||
email : jef at norbit dot de | ||
*************************************************************************** | ||
* * | ||
* 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 "qgsslconnect.h" | ||
|
||
#include <sqlite3.h> | ||
#include <spatialite.h> | ||
|
||
#if defined(SPATIALITE_HAS_INIT_EX) | ||
QHash<sqlite3 *, void *> QgsSLConnect::mSLconns; | ||
#endif | ||
|
||
int QgsSLConnect::sqlite3_open( const char *filename, sqlite3 **ppDb ) | ||
{ | ||
#if defined(SPATIALITE_HAS_INIT_EX) | ||
void *conn = spatialite_alloc_connection(); | ||
#else | ||
spatialite_init( 0 ); | ||
#endif | ||
|
||
int res = ::sqlite3_open( filename, ppDb ); | ||
|
||
#if defined(SPATIALITE_HAS_INIT_EX) | ||
if ( res == SQLITE_OK ) | ||
{ | ||
spatialite_init_ex( *ppDb, conn, 0 ); | ||
mSLconns.insert( *ppDb, conn ); | ||
} | ||
#endif | ||
|
||
return res; | ||
} | ||
|
||
int QgsSLConnect::sqlite3_close( sqlite3 *db ) | ||
{ | ||
int res = ::sqlite3_close( db ); | ||
|
||
#if defined(SPATIALITE_HAS_INIT_EX) | ||
if ( mSLconns.contains( db ) ) | ||
spatialite_cleanup_ex( mSLconns.take( db ) ); | ||
#endif | ||
|
||
return res; | ||
} | ||
|
||
int QgsSLConnect::sqlite3_open_v2( const char *filename, sqlite3 **ppDb, int flags, const char *zVfs ) | ||
{ | ||
#if defined(SPATIALITE_HAS_INIT_EX) | ||
void *conn = spatialite_alloc_connection(); | ||
#else | ||
spatialite_init( 0 ); | ||
#endif | ||
|
||
int res = ::sqlite3_open_v2( filename, ppDb, flags, zVfs ); | ||
|
||
#if defined(SPATIALITE_HAS_INIT_EX) | ||
if ( res == SQLITE_OK ) | ||
{ | ||
spatialite_init_ex( *ppDb, conn, 0 ); | ||
mSLconns.insert( *ppDb, conn ); | ||
} | ||
#endif | ||
|
||
return res; | ||
} | ||
|
||
int QgsSLConnect::sqlite3_close_v2( sqlite3 *db ) | ||
{ | ||
int res = ::sqlite3_close( db ); | ||
|
||
#if defined(SPATIALITE_HAS_INIT_EX) | ||
if ( mSLconns.contains( db ) ) | ||
spatialite_cleanup_ex( mSLconns.take( db ) ); | ||
#endif | ||
|
||
return res; | ||
} |
Oops, something went wrong.