-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Michael Roth wrote:
| WysG wrote:
|> //=====================================================
|> CRecordset CConnection::query(const char *sqlQuery)
|> {
|>     if(this->db)
|>     {
|>         CRecordset oRs;
|>         oRs.oConn = this;
|>                int result = sqlite3_prepare((sqlite3*)this->db,
|> sqlQuery, -1, (sqlite3_stmt**)&oRs.vm, NULL); //Not sure if I'm
|> forgetting something to do before the prepare.
|>
|>         if(result != SQLITE_OK)
|>             throw CDBException("Error on query");
|>                oRs.columnCount =
|> sqlite3_column_count((sqlite3_stmt*)oRs.vm);
|>
|>         return oRs;
|>     }
|
|
| Look: After the 'if(this->db) {' you create an CRecordset object 'oRs'
| on the stack. Calling sqlite3_prepare() you store the statement in
| '&oRs.vm'. After the closing '}' your CRecordset object 'oRs' on the
| stack gets destroyed. I assume your CRecordset::~CRecordset() destructor
| calls sqlite3_finalize() on his member 'vm'. The destructor will be
| always called on 'oRs' because this object lives on the stack.
| Additionally it's copy-operator is called in the 'return oRs;' statement
| to construct the object which will returned to the caller.

Thanks alot, the problem was indeed that the destructor was calling
sqlite3_finalize on vm.
- --
WysG
"Codito Ergo Sum" - 'I code, therefore I am' - 'Je code, donc je suis'
GPG Public Key : http://wysg.hextudio.com/WysG.gpg
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)

iD8DBQFBH3MbgQbMyvdsS5ARAhbwAKCivioQ/RuZQtq5Kf66C5l5sXUWcwCghz9b
GMLHNv9Ybl5B/G0iMGONIOM=
=CQ2E
-----END PGP SIGNATURE-----



Reply via email to