[Interest] QSqlQueryModel.... Warning when query is replaced

Guido Seifert wargand at gmx.de
Thu Mar 12 09:30:55 CET 2015


Hi,

I have a QSqlQueryModel, which I feed a query with setQuery(const QSqlQuery & query).
Works great the first time I do this. Works too, if I use setQuery(const QSqlQuery & query)
a second+ time to change the query. However, after the 1st time I get on the console:

> ?libqsqlpsql.so? -- 0 -- Unable to free statement: ERROR:  prepared statement "qpsqlpstmt_<X>" does not exist

The program works as expected, but messages like that make me a bit nervous and I try everything to get rid 
of them. The only way I found to avoid this was to create for each setQuery call a QSqlQuery on the heap and
never delete it... ugly memory leak.

Here is a similar bug report on SO:
http://stackoverflow.com/questions/12888134/qtsql-prepared-statement-qpsqlpstmt-1-does-not-exist-on-clear-of-model

I don't call clear on my QSqlQueryModel (though I tried this too) before I deleted the query. I suppose the destructor 
of QSqlQuery does something after the db connection was dropped.

Anyone a comment on this before I write a possibly useless bug report?

Guido




More information about the Interest mailing list