-
Notifications
You must be signed in to change notification settings - Fork 18
Conversation
@flanfly soo, ehh, what is the use case? Any examples? |
A simple example would be a long running function that's called from QML. While the function is running, the GUI freezes. Calling loop {
engine.send_posted_events();
engine.process_events();
if !dispatch_my_events() {
break;
}
} |
while it can be done, it is generally highly recommended to run any longer Through a reason could be to merge another event loop into the main event So if it is not much overhead it might not hurt and get some usages, |
well, it looks like a safe, strait and simple forwarding of a DOS function, so why not 😄 |
Hey @dathinab. I actually do launch threads for long running tasks and this is a reason I need my own event loop in the main thread. When the thread finishes I need to manipulate QObjects to signal the QML side that new data is available. This can only be done from the main thread. |
ok, through can't you use signals? They are thread safe as far as I know (through their data might not). |
Edit: For this a QObject would need to live in the new thread and emit a signal when it's done. |
Oh, I was not aware of this. In this case just ignore what I said before On Fri, Nov 18, 2016, 19:57 Kai Michaelis notifications@github.com wrote:
|
This is, actually, a big problem -- whether It is easily made into one, but I'm not sure if underlying Qt's object is thread-safe. There is an example in this repo, that shows, that it is ok to call signals from other threads, but I didn't check if it is okay to do this with slots as well. @flanfly will it solve your problem, if Edit: |
Hey @White-Oak, using your |
@flanfly definetily! Thanks for the suggestion |
Exposes sendPostedEvents and processEvents. See filcuc/dotherside#49 for details.