Reimplementing winEvent: getting stuck in API call
I got this answer from JRMC:
Using PlaybackAutomationPtr from a worker thread could cause trouble, because internally it sends messages to the player window. Especially if the handling of these messages fires an event that tries to re-enter your event handler.
Instead, I would recommend posting MCC messages to the player if you’re in a worker thread.
PostMessage(MJ.GetWindowHandle(), WM_MC_COMMAND, MCC_PLAY_CPLDB_INDEX, -1);
PostMessage is ok for Play() Pause() commands, bu it wont work when I need to retrieve informations from the COM.
I got something working by following these tips:
BTW the code I uploaded was full of bugs, I was emiting slots!
_I had to connect my re-emitted signal to a custom slot with Qt::QueuedConnection [doc.qt.nokia.com]. Otherwise it does not work.
_I am supposed to return values to the API through the winEvent(MSG* msg, long* result);
However, since I have to re-emit from winEvent to get this working, winEvent() returns before I set the long* result to the desired value. So I’m stuck once again.
I have changed the way I interface the COM object, and now with this code:
- bool Bridge::winEvent(MSG *message, long *result)
- if( message->message == WM_USER && message->hwnd == winId() )
- return true;
- // give the event to qt
- return false;
While if I call myQAxObject->dynamicCall(“Play()”); from anywhere else in my code it works.