Can Q_GLOBAL_STATIC replace KStaticDelete ?

Matthias Kretz Matthias.Kretz at urz.uni-heidelberg.de
Mon Jan 8 20:15:27 GMT 2007


This made me locate the problem:

********* Finished testing of MethodTest *********
QCoreApplication::postEvent: Receiver is not a valid QObject
QCoreApplication::postEvent: Receiver is not a valid QObject
QEventLoop: Cannot be used without QApplication
QCoreApplication::postEvent: Receiver is not a valid QObject
QCoreApplication::postEvent: Receiver is not a valid QObject
QEventLoop: Cannot be used without QApplication
QCoreApplication::postEvent: Receiver is not a valid QObject
QCoreApplication::postEvent: Receiver is not a valid QObject
QEventLoop: Cannot be used without QApplication
QCoreApplication::postEvent: Receiver is not a valid QObject
QCoreApplication::postEvent: Receiver is not a valid QObject
QEventLoop: Cannot be used without QApplication
phonon (core): [virtual Phonon::Xine::ByteStream::~ByteStream()]
QCoreApplication::postEvent: Receiver is not a valid QObject
phonon (core): [virtual Phonon::Xine::ByteStream::~ByteStream()]
QCoreApplication::postEvent: Receiver is not a valid QObject
phonon (core): [virtual Phonon::Xine::ByteStream::~ByteStream()]
QCoreApplication::postEvent: Receiver is not a valid QObject
phonon (core): [virtual Phonon::Xine::ByteStream::~ByteStream()]
QCoreApplication::postEvent: Receiver is not a valid QObject
phonon (core): [virtual Phonon::Xine::ByteStream::~ByteStream()]
QCoreApplication::postEvent: Receiver is not a valid QObject
phonon (core): [virtual Phonon::Xine::ByteStream::~ByteStream()]
QCoreApplication::postEvent: Receiver is not a valid QObject
phonon (core): [virtual Phonon::Xine::ByteStream::~ByteStream()]
QCoreApplication::postEvent: Receiver is not a valid QObject

The test just hangs at this point...

using gdb:
(gdb) thread 1
[Switching to thread 1 (Thread -1234319168 (LWP 9235))]#0  
QCoreApplication::postEvent (receiver=0x80e5730, event=0x80bcd30)
    at /media/hda7/KDE/src/qt-copy/src/corelib/kernel/qcoreapplication.cpp:813
813             qWarning("QCoreApplication::postEvent: Receiver is not a valid 
QObject");
(gdb) print receiver
$3 = (class QObject *) 0x80e5730
(gdb) thread 7
[Switching to thread 7 (Thread -1283228768 (LWP 9251))]#0  0xffffe410 in 
__kernel_vsyscall ()
(gdb) bt
#0  0xffffe410 in __kernel_vsyscall ()
#1  0xb6968321 in ___newselect_nocancel () from /lib/tls/i686/cmov/libc.so.6
#2  0xb7f1ff2a in QEventDispatcherUNIX::select (this=0x80e7088, nfds=23, 
readfds=0x80e70e8, writefds=0x80e726c, exceptfds=0x80e73f0, timeout=0x0)
at /media/hda7/KDE/src/qt-copy/src/corelib/kernel/qeventdispatcher_unix.cpp:309
#3  0xb7f20378 in QEventDispatcherUNIXPrivate::doSelect (this=0x80e7098, 
flags=@0xb383731c, timeout=0x0)
at /media/hda7/KDE/src/qt-copy/src/corelib/kernel/qeventdispatcher_unix.cpp:124
#4  0xb7f209c8 in QEventDispatcherUNIX::processEvents (this=0x80e7088, 
flags=@0xb383735c)
at /media/hda7/KDE/src/qt-copy/src/corelib/kernel/qeventdispatcher_unix.cpp:700
#5  0xb7ef495c in QEventLoop::processEvents (this=0xb38373cc, 
flags=@0xb3837394) 
at /media/hda7/KDE/src/qt-copy/src/corelib/kernel/qeventloop.cpp:126
#6  0xb7ef4ade in QEventLoop::exec (this=0xb38373cc, flags=@0xb38373d4) 
at /media/hda7/KDE/src/qt-copy/src/corelib/kernel/qeventloop.cpp:168
#7  0xb7e4dec9 in QThread::exec (this=0x80e5730) 
at /media/hda7/KDE/src/qt-copy/src/corelib/thread/qthread.cpp:402
#8  0xb65f4b29 in Phonon::Xine::XineStream::run (this=0x80e5730) 
at /home/mkretz/KDE/src/branches/work/phonon-xine-threaded/xinestream.cpp:996
#9  0xb7e5075b in QThreadPrivate::start (arg=0x80e5730) 
at /media/hda7/KDE/src/qt-copy/src/corelib/thread/qthread_unix.cpp:146
#10 0xb7e0a504 in start_thread () from /lib/tls/i686/cmov/libpthread.so.0
#11 0xb696f51e in clone () from /lib/tls/i686/cmov/libc.so.6

With QCoreApplication gone the main thread cannot postEvents to the other 
thread anymore, which is needed to cleanly exit the thread.

Using Solid a similar warning appeared:
QObject::startTimer: QTimer can only be used with threads started with QThread

The reason is that KLibrary wants to start a QTimer when the factory object is 
destroyed. (I committed a fix that checks for the presence of 
QCoreApplication::instance(), so that this warning is gone by now.)

On Monday 08 January 2007 19:56, Thiago Macieira wrote:
> I saw the commit, but it doesn't explain why there is such a requirement.
>
> Why must those objects be deleted before QCoreApplication does away? Or
> why must they be deleted between QCoreApplication's destructor and the
> application's real exit?
>
> What happens to those objects if the application exits without
> QCoreApplication's destructor running?

-- 
________________________________________________________
Matthias Kretz (Germany)                            <><
http://Vir.homelinux.org/
MatthiasKretz at gmx.net, kretz at kde.org,
Matthias.Kretz at urz.uni-heidelberg.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070108/e6f4fe96/attachment.sig>


More information about the kde-core-devel mailing list