Application Crash if sending very fast to QApplication::instance()->postEvent
-
Why do you want to send events to focused widget? What if another widget gets focus?
And why don't you use signals/slots?
Are you sure you need multi-threading? You can do TCP communication asynchronously in Qt. -
Hi,
the architecture is needed because we are running multiple applications which communicate with each other.
I also did the same implementation using a signal/slot approach but it also crashes if it gets under high load.The background of this is to simulate user interaction by sending a XML command to the Main Application which then calls the QT part.
If i put a sleep of 1 sec after posting the events it works , so I am wondering why it crashes if it gets fast events.
It seems to process handling crashes on fast calls (50-100 events a sec).
Many Thanks
-
Where exactly does your application crash?
Maybe you just have an synchronisation issue in your code since you use multi-threading. -
Hi,
I narrowed it down that it crash during postEvent call.If i comment the postEvent out all works fine. Also If I set a sleep from 500 ms it works.
Maybe the other application sends too fast the events that qt does not have time to handle them and then crashes?
-
Are you sure it is the postEvent call itself and not the code which is triggered by postEvent?
-
I mean do you have any code which is executed when you call postEvent? So, do you have any event handlers?
Yes it can happen that after if(focus) focus is not valid any more. This is one of the problem you can get in multi-threaded applications. -
Hi,
I just let the GUI handle the event .
For example if a button is focused and it gets the event for pressing the key the screen will change to a different widget. Or if left right is posted by the events the focus will move in the widget to a different button.But the events are handled in the widgets themselves then, so no bypass done here just normal Qt implementation with Signal and Slots.
Regards
-
Since you are running several applications, why not use IPC in your design ? That way you wouldn't need to do hacks to communicate between them