Skip to content
Permalink
Browse files
depend on spatialite_init_ex() for 'new' spatialite initialization (f…
…ollowup 252aaab)
  • Loading branch information
jef-n committed May 27, 2015
1 parent f67a08a commit d4b72a2d7be13854458b6ea3b9535bbee2461a71
Showing with 11 additions and 7 deletions.
  1. +3 −0 CMakeLists.txt
  2. +1 −0 cmake/FindSPATIALITE.cmake
  3. +6 −6 src/core/qgsslconnect.cpp
  4. +1 −1 src/core/qgsslconnect.h
@@ -220,6 +220,9 @@ ENDIF(SPATIALITE_VERSION_GE_4_0_0)
IF(SPATIALITE_VERSION_G_4_1_1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSPATIALITE_VERSION_G_4_1_1")
ENDIF(SPATIALITE_VERSION_G_4_1_1)
IF(SPATIALITE_HAS_INIT_EX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSPATIALITE_HAS_INIT_EX")
ENDIF(SPATIALITE_HAS_INIT_EX)

IF (NOT PROJ_FOUND OR NOT GEOS_FOUND OR NOT GDAL_FOUND)
MESSAGE (SEND_ERROR "Some dependencies were not found!")
@@ -70,6 +70,7 @@ IF (SPATIALITE_FOUND)
ENDIF(APPLE)
check_library_exists("${SPATIALITE_LIBRARY}" gaiaDropTable "" SPATIALITE_VERSION_GE_4_0_0)
check_library_exists("${SPATIALITE_LIBRARY}" gaiaStatisticsInvalidate "" SPATIALITE_VERSION_G_4_1_1)
check_library_exists("${SPATIALITE_LIBRARY}" spatialite_init_ex "" SPATIALITE_HAS_INIT_EX)

ELSE (SPATIALITE_FOUND)

@@ -24,15 +24,15 @@ QHash<sqlite3 *, void *> QgsSLConnect::mSLconns;

int QgsSLConnect::sqlite3_open( const char *filename, sqlite3 **ppDb )
{
#if defined(SPATIALITE_VERSION_GE_4_0_0)
#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_VERSION_GE_4_0_0)
#if defined(SPATIALITE_HAS_INIT_EX)
if ( res == SQLITE_OK )
{
spatialite_init_ex( *ppDb, conn, 0 );
@@ -47,7 +47,7 @@ int QgsSLConnect::sqlite3_close( sqlite3 *db )
{
int res = ::sqlite3_close( db );

#if defined(SPATIALITE_VERSION_GE_4_0_0)
#if defined(SPATIALITE_HAS_INIT_EX)
if ( mSLconns.contains( db ) )
spatialite_cleanup_ex( mSLconns.take( db ) );
#endif
@@ -57,15 +57,15 @@ int QgsSLConnect::sqlite3_close( sqlite3 *db )

int QgsSLConnect::sqlite3_open_v2( const char *filename, sqlite3 **ppDb, int flags, const char *zVfs )
{
#if defined(SPATIALITE_VERSION_GE_4_0_0)
#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_VERSION_GE_4_0_0)
#if defined(SPATIALITE_HAS_INIT_EX)
if ( res == SQLITE_OK )
{
spatialite_init_ex( *ppDb, conn, 0 );
@@ -80,7 +80,7 @@ int QgsSLConnect::sqlite3_close_v2( sqlite3 *db )
{
int res = ::sqlite3_close( db );

#if defined(SPATIALITE_VERSION_GE_4_0_0)
#if defined(SPATIALITE_HAS_INIT_EX)
if ( mSLconns.contains( db ) )
spatialite_cleanup_ex( mSLconns.take( db ) );
#endif
@@ -29,7 +29,7 @@ class CORE_EXPORT QgsSLConnect
static int sqlite3_open_v2( const char *filename, sqlite3 **ppDb, int flags, const char *zVfs );
static int sqlite3_close_v2( sqlite3* );

#if defined(SPATIALITE_VERSION_GE_4_0_0)
#if defined(SPATIALITE_HAS_INIT_EX)
private:
static QHash<sqlite3 *, void *> mSLconns;
#endif

0 comments on commit d4b72a2

Please sign in to comment.