Lukas Oberhuber wrote:
I did a little research and something strange is happening here in the stack
trace.

The call to eventFilter ThreadEventFilter::eventFilter(QObject * watched=0x039c1628, QEvent *
event=0x105c5740)  Line 34      C++

is not doing what I would expect. Below the code of the method (it crashes
on the call to threadEvent->callback()):

--code--
bool ThreadEventFilter::eventFilter(QObject * watched, QEvent * event) {
        if (event->type() == QtThreadEvent::EventValue) {
                QtThreadEvent * threadEvent = (QtThreadEvent *) event;
                threadEvent->callback();
                return true;
        }
        return QObject::eventFilter(watched, event);
}
--code--

The code for QtThreadEvent::callback() is the following (line 56) which is
what we would expect to be called based on the cast:

--code--
        void callback() {
                _threadEventPrivate->callback();
        }
--code--

but this method is not called. Instead, this other method is called.
        qtwengophone.exe!ThreadEvent3<void
__cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
,std::basic_string<char,std::char_traits<char>,std::allocator<char>
,std::basic_string<char,std::char_traits<char>,std::allocator<char>
),std::basic_string<char,std::char_traits<char>,std::allocator<char>
,std::basic_string<char,std::char_traits<char>,std::allocator<char>
,std::basic_string<char,std::char_traits<char>,std::allocator<char> >
::callback()  Line 161  C++

I did my own investigations, and I believe I have an explanation for this (but not for the crash :-( ). Here it is:

All begins in CContactList::contactMovedEventHandler(). It creates a ThreadEvent3<std::string, std::string, std::string> event (let's call it event3) and posts it using PFactory::postEvent().

The Qt implementation of PFactory::postEvent() wraps the event it received in a QtThreadEvent (let's call it qtevent), and posts qtevent using QCoreApplication::postEvent().

ThreadEventFilter::eventFilter() receives all events posted using QCoreApplication::postEvent(), so it receives qtevent, casts it to a QtThreadEvent and calls qtevent->callback().

qtevent wraps event3, so qtevent->callback() calls event3->callback().

The reason why you don't see the code going through QtThreadEvent::callback() is probably because the code for this method is in QtThreadEvent.h, so it's inlined by the compiler and does not appear in the backtrace.

As a conclusion, I would say that the event system is working correctly. If the pointers passed to event3 are garbage, this is probably caused by wrong code in either CContactList or ContactList. It would be nice if you could get to check if the references passed to CContactList::contactMovedEventHandler are valid.

Aurélien
_______________________________________________
Wengophone-devel mailing list
[email protected]
http://dev.openwengo.com/mailman/listinfo/wengophone-devel

Reply via email to