Skip to content

Commit

Permalink
depend on spatialite_init_ex() for 'new' spatialite initialization (f…
Browse files Browse the repository at this point in the history
…ollowup 252aaab)
  • Loading branch information
jef-n committed May 27, 2015
1 parent f67a08a commit d4b72a2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
Expand Down
1 change: 1 addition & 0 deletions cmake/FindSPATIALITE.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
12 changes: 6 additions & 6 deletions src/core/qgsslconnect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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
Expand All @@ -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 );
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsslconnect.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d4b72a2

Please sign in to comment.