diff --git a/src/mirall/ownsql.cpp b/src/mirall/ownsql.cpp index a563a7c04..c87fb05a1 100644 --- a/src/mirall/ownsql.cpp +++ b/src/mirall/ownsql.cpp @@ -286,11 +286,4 @@ void SqlQuery::reset() SQLITE_DO(sqlite3_reset(_stmt)); } -void SqlQuery::closeDb() -{ - if( _db) { - SQLITE_DO(sqlite3_close(_db) ); - _db = 0; - } -} } // namespace Mirall diff --git a/src/mirall/ownsql.h b/src/mirall/ownsql.h index ee409437c..eacd5b3e0 100644 --- a/src/mirall/ownsql.h +++ b/src/mirall/ownsql.h @@ -57,9 +57,6 @@ public: quint64 int64Value(int index); QByteArray baValue(int index); - // use only in rare cases, invalidates the internal db object. - void closeDb(); - bool isSelect(); bool isPragma(); bool exec(); diff --git a/src/mirall/socketapi.cpp b/src/mirall/socketapi.cpp index c5e3c93d3..bf61a4970 100644 --- a/src/mirall/socketapi.cpp +++ b/src/mirall/socketapi.cpp @@ -229,10 +229,16 @@ void SocketApi::slotUnregisterPath( const QString& alias ) SqlQuery *h = _dbQueries[f]; if( h ) { h->finish(); - h->closeDb(); } _dbQueries.remove(f); } + if( _openDbs.contains(f) ) { + SqlDatabase *db = _openDbs[f]; + if( db ) { + db->close(); + } + _openDbs.remove(f); + } } } @@ -393,7 +399,9 @@ SqlQuery* SocketApi::getSqlQuery( Folder *folder ) if( fi.exists() ) { SqlDatabase *db = new SqlDatabase; - if( db->open(dbFileName) ) { + if( db && db->open(dbFileName) ) { + _openDbs.insert(folder, db); + SqlQuery *query = new SqlQuery(*db); rc = query->prepare(sql); diff --git a/src/mirall/socketapi.h b/src/mirall/socketapi.h index a46b567e1..24460bd87 100644 --- a/src/mirall/socketapi.h +++ b/src/mirall/socketapi.h @@ -86,6 +86,7 @@ private: QList _listeners; c_strlist_t *_excludes; QHash _dbQueries; + QHash _openDbs; }; }