Skip to content
Permalink
Browse files

delete spatialite_database_unique_ptr::reset( sqlite3 * )

  • Loading branch information
m-kuhn committed Nov 15, 2017
1 parent 48e8656 commit 35808f199b5ff3080759c6341e3c4b1d6632eac6
@@ -33,7 +33,7 @@ int spatialite_database_unique_ptr::open( const QString &path )

sqlite3 *database = nullptr;
int result = sqlite3_open( path.toUtf8(), &database );
reset( database );
std::unique_ptr< sqlite3, QgsSpatialiteCloser>::reset( database );

#if defined(SPATIALITE_HAS_INIT_EX)
if ( result == SQLITE_OK )
@@ -43,6 +43,11 @@ int spatialite_database_unique_ptr::open( const QString &path )
return result;
}

void spatialite_database_unique_ptr::reset()
{
std::unique_ptr< sqlite3, QgsSpatialiteCloser>::reset();
}

int spatialite_database_unique_ptr::open_v2( const QString &path, int flags, const char *zVfs )
{
#if defined(SPATIALITE_HAS_INIT_EX)
@@ -54,7 +59,7 @@ int spatialite_database_unique_ptr::open_v2( const QString &path, int flags, con

sqlite3 *database = nullptr;
int result = sqlite3_open_v2( path.toUtf8(), &database, flags, zVfs );
reset( database );
std::unique_ptr< sqlite3, QgsSpatialiteCloser>::reset( database );

#if defined(SPATIALITE_HAS_INIT_EX)
if ( result == SQLITE_OK )
@@ -64,6 +64,20 @@ class CORE_EXPORT spatialite_database_unique_ptr : public std::unique_ptr< sqlit
*/
int open( const QString &path );

/**
* Will close the connection and set the internal pointer to nullptr.
*/
void reset();

/**
* It is not allowed to set an arbitrary sqlite3 handle on this object.
*
* A dedicated spatialite context (connection) is created when calling open or
* open_v2. This context needs to be kept together with the handle, hence it is
* not allowed to reset to a handle with missing context.
*/
void reset( sqlite3 *handle ) = delete;

/**
* Opens the database at the specified file \a path.
*
@@ -494,16 +494,6 @@ QSpatiaLiteDriver::QSpatiaLiteDriver(QObject * parent)
d = new QSpatiaLiteDriverPrivate();
}

QSpatiaLiteDriver::QSpatiaLiteDriver(sqlite3 *connection, QObject *parent)
: QSqlDriver(parent)
{
d = new QSpatiaLiteDriverPrivate();
d->access.reset( connection );
setOpen(true);
setOpenError(false);
}


QSpatiaLiteDriver::~QSpatiaLiteDriver()
{
delete d;
@@ -92,10 +92,7 @@ class Q_EXPORT_SQLDRIVER_SQLITE QSpatiaLiteDriver : public QSqlDriver
friend class QSpatiaLiteResult;
public:
explicit QSpatiaLiteDriver(QObject *parent = 0);
/**
* Ownership of \a connection is taken.
*/
explicit QSpatiaLiteDriver(sqlite3 *connection, QObject *parent = 0);

~QSpatiaLiteDriver();
bool hasFeature(DriverFeature f) const;
bool open(const QString & db,

0 comments on commit 35808f1

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