Skip to content

Commit

Permalink
[MSSQL] Close database and delete query on close
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Mar 26, 2014
1 parent d047ea0 commit 8c4bfa3
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/providers/mssql/qgsmssqlfeatureiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ QgsMssqlFeatureIterator::QgsMssqlFeatureIterator( QgsMssqlFeatureSource* source,
QgsMssqlFeatureIterator::~QgsMssqlFeatureIterator()
{
close();

if ( mQuery )
delete mQuery;

if (mDatabase.isOpen())
mDatabase.close();
}

void QgsMssqlFeatureIterator::BuildStatement( const QgsFeatureRequest& request )
Expand Down Expand Up @@ -224,6 +218,9 @@ bool QgsMssqlFeatureIterator::fetchFeature( QgsFeature& feature )

bool QgsMssqlFeatureIterator::rewind()
{
if ( mClosed )
return false;

if ( mStatement.isEmpty() )
{
QgsDebugMsg( "QgsMssqlFeatureIterator::rewind on empty statement" );
Expand Down Expand Up @@ -260,6 +257,12 @@ bool QgsMssqlFeatureIterator::close()
mQuery->finish();
}

if ( mQuery )
delete mQuery;

if (mDatabase.isOpen())
mDatabase.close();

iteratorClosed();

mClosed = true;
Expand Down

0 comments on commit 8c4bfa3

Please sign in to comment.