Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, May 2008
'qt_sql_default_connection' is still in use


Message 1 in thread

Upon exit from my application I receive strange warning:
Warning: QSqlDatabasePrivate::removeDatabase: connection 
'qt_sql_default_connection' is still in use, all queries will cease to work.

What does it mean and where to look?
QT 4.3.4 


--
 [ signature omitted ] 

Message 2 in thread

George wrote on Saturday, 17 May 2008 06:22: 

> Upon exit from my application I receive strange warning:
> Warning: QSqlDatabasePrivate::removeDatabase: connection 
> 'qt_sql_default_connection' is still in use, all queries will 
> cease to work.
> 
> What does it mean and where to look?
> QT 4.3.4 

Hi George, 

I had the same problem, the main window had a QSqlDatabase member object
(that is, not a pointer), and IIRC was trying to disconnect the database in
the main window destructor. The solution was to destroy the main window
object in your 'main' routine, after qApp->exec() returns (by making it a
local variable in my case). You could probably just change the database
member to be a pointer as well. 

Hope that helps, 

Tony Rietwyk

--
 [ signature omitted ] 

Message 3 in thread

"Tony Rietwyk" <tony.rietwyk@xxxxxxxxxxxxxxxx> wrote in message 
news:000b01c8b7a6$39e62f60$83cfa8c0@xxxxxxxxxxxxxxx
> George wrote on Saturday, 17 May 2008 06:22:
>
>> Upon exit from my application I receive strange warning:
>> Warning: QSqlDatabasePrivate::removeDatabase: connection
>> 'qt_sql_default_connection' is still in use, all queries will
>> cease to work.
>>
>> What does it mean and where to look?
>> QT 4.3.4
>
> Hi George,
>
> I had the same problem, the main window had a QSqlDatabase member object
> (that is, not a pointer),

Actually, I tried to make QSqlDatabase object global....
I want to be able to redefine databaseName/userName/password/etc several 
times inside DatabaseLoginDialog's "Ok" button. So I tried to use 
addDatabase() once in my main() module and access created db object from 
class DatabaseLoginDialog...


> and IIRC was trying to disconnect the database in
> the main window destructor. The solution was to destroy the main window
> object in your 'main' routine, after qApp->exec() returns (by making it a
> local variable in my case).
You mean something like this:
---------------
QSqlDatabase db;
MainWindow *mainWindow;
int main(int argc, char **argv) {
    QApplication app(argc, argv);
    db = QSqlDatabase::addDatabase("QSQLITE");
    mainWindow = new MainWindow();
    mainWindow->show();
    int rc = app.exec();
    QSqlDatabase::removeDatabase( QLatin1String( defaultConnection ) );
    return rc;
}
------------
I'll try.

> You could probably just change the database member to be a pointer as 
> well.
I am not sure you can make a normal pointer to a 'value' class.
 


--
 [ signature omitted ] 

Message 4 in thread

George Brink wrote:
> "Tony Rietwyk" <tony.rietwyk@xxxxxxxxxxxxxxxx> wrote in message
> news:000b01c8b7a6$39e62f60$83cfa8c0@xxxxxxxxxxxxxxx
>> George wrote on Saturday, 17 May 2008 06:22:
>>
>>> Upon exit from my application I receive strange warning:
>>> Warning: QSqlDatabasePrivate::removeDatabase: connection
>>> 'qt_sql_default_connection' is still in use, all queries will
>>> cease to work.
>>>
>>> What does it mean and where to look?
>>> QT 4.3.4
>>
>> Hi George,
>>
>> I had the same problem, the main window had a QSqlDatabase member object
>> (that is, not a pointer),
>
> Actually, I tried to make QSqlDatabase object global....
> I want to be able to redefine databaseName/userName/password/etc
> several times inside DatabaseLoginDialog's "Ok" button. So I tried to
> use addDatabase() once in my main() module and access created db
> object from class DatabaseLoginDialog...
Yes, this seems to be a definate issue, as the warning I think comes
from shutdown of the application object. It's on my list of things to
investigate and see if I can do it better (ie, add a global warning that
kicks in after the globals have had a  chance to destruct). Don't hold
your breath on it tho, as there's a fair amount of work above it on my
todo list.


-- 
 [ signature omitted ]