[Qt-interest] Returning arbitrary value with QApplication::exit()

Diego Schulz dschulz at gmail.com
Sat Jun 27 16:53:45 CEST 2009


On Sat, Jun 27, 2009 at 12:08 AM, Girish
Ramakrishnan<girish at forwardbias.in> wrote:
> It is not wrong but I will not recommend this. If your db connection is
> lost, why not just reconnect? Or if you want to make it simple, destroy
> all your db/connection objects and start afresh. Why do you need to
> destroy QApplication itself?
>

Yes, I tried, really.

What I try to avoid is to get those nasty warnings such as

QSqlDatabasePrivate::removeDatabase: connection 'conn1' is still in
use, all queries will cease to work.

Using QSqlTableModel and other classes cause these warnings to be
printed if you don't let it die in the correct order, ie. you manually
destroy a connection but there's still a component that's pointing to
it.
The parent/child mechanism does a good work deleting objects when the
QApplication is terminating, without warnings.

I failed miserably trying to figure out a design that is robust but at
the same time not too complex. In my opinion, the QtSql module lacks
some flexibility (and functionality too). It forces to use the same
pattern, even if it's not the appropiate in some cases.

>
> The reason to not use it is, as Andreas Pakulat, said is that you will
> find probably find hard to track errors. 'probably' is the keyword,
> since no on does it this way, it is unlikely all this is well tested by
> Qt users or developers. Besides QApplication has very many static
> functions and atleast it used to rely on lots of static data. For your
> code to work, the QApplication code must init/uninit correctly. Since
> the the process exits immediately after qApp is destroyed no one notices
> if things were uninited correctly.
>
> Again, I am not saying it is wrong, just that if you want to 'get things
> done asap', I won't recommend it.
>
>
> Girish
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>



More information about the Qt-interest-old mailing list