QFutureWatcher's signal finished does not get emitted.
-
Hi,
What about calling
signalObj->deleteLater()
in place ofdelete
? -
@0xedd1e
Hi
Are you running ScriptInstance in another thread? (movetothread style)
Have you checked you can emit a signal and have a slot called in the class ?
( or the actual worker thread if that is the case)I tried Wielands code in main thread and it worked so i wondering
if its something with emitting signals from your actual code.
(clearly it is but i mean in general)So forget about async/QFutureWatcher for a moment and simply emit a signal to a slot
on same level/class/interclass as the QFutureWatcher is running.Sorry if you already validated other signals do work. It was just a thought.
-
@mrjj
I've now done the following;- Added a new signal, signalDebug(), to ScriptInstance class.
- Connected signalDebug() to slot slotFinished() in the constructor for ScriptInstance class.
- In ScriptInstance::scriptExecutionThread() I emitted the signalDebug() signal.
Result: slotFinished() is called just fine.
FYI: I'm also back to using QtConcurrent mechanisms.
-
@0xedd1e
Ok, so signals seems to work.
I was wondering if you needed to specify connection type
but if some signals work, all should.but just for test
connect(&_scriptWatcher, &QFutureWatcher<void>::finished, this, &ScriptInstance::slotFinished, Qt::QueuedConnection);Else Im a bit out of idea as all seem ok.
Update
I ran your code and slotFinished was called ?
Can you try it
https://www.dropbox.com/s/rhdk6xxk323ziqh/test_thread.zip?dl=0 -
@mrjj
Once I discovered the issue I experimented with different type of connections, but no change in behavior.The project you provided works just fine, so I guess that rules out that there is no issue(s) related to my setup at least.
The ScriptEngine in my case is a singleton, but I don't see why that should matter in this case since all other signals/slots seems to work just fine.
-
@0xedd1e
Ok. super. Yes it means nothing wrong inside Qt/the setup.- ScriptEngine in my case is a singleton
meaning its static ?
But I agree if other signals can get be emitted (from same nesting level) then
it seems unlikely its that. -
@mrjj
Correct, it is static.I'm really out of ideas, so I guess I have to go back to earlier changesets within my project and see if I can pinpoint the exact change that caused this behavior. However, the code connected to the script engine and script instance hasn't changed for quite a while though, so I'll try to back the project to an earlier changeset and see if there are changes elsewhere that causes this. I registered a bug in my own ticket system when I discovered this issue but marked it for check-later-when-qt-upgrades since it worked fine in QT 5.4 and earlier.
Thanks again for all the feedback and I'll report back during the upcoming holiday.
-
@0xedd1e said in QFutureWatcher's signal finished does not get emitted.:
@mrjj
Correct, it is static.I'm really out of ideas, so I guess I have to go back to earlier changesets within my project and see if I can pinpoint the exact change that caused this behavior. However, the code connected to the script engine and script instance hasn't changed for quite a while though, so I'll try to back the project to an earlier changeset and see if there are changes elsewhere that causes this. I registered a bug in my own ticket system when I discovered this issue but marked it for check-later-when-qt-upgrades since it worked fine in QT 5.4 and earlier.
Thanks again for all the feedback and I'll report back during the upcoming holiday.
FYI;
I've now gone back and tested previous versions of the project but can't seem to get it working in any of the earlier versions now using QT 5.10. So I guess something has changed in QT, but I can't figure out what though and to my knowledge I follow the recommendations according to the documentation of QT.Worth trying going back to using earlier versions of QT?
-
@0xedd1e
Hi I also looked at the release notes to see
if something with Future/Concurrent was changed but nothing popped up.- Worth trying going back to using earlier versions of QT?
Well for test. it would be a good test if exact same code just works in say 5.6
and not in 5.10. But being stucked at 5.4 would be not so optimal.A note about the static.
Just to be sure. the class that expects the Finished signal is a static member of some other class?
As far as i can recall, you cant compile if you try to connect to a static class slot so im inclided to
say that is not the issue.Since your mini sample works. There must be some difference in the real code. But i cant
think of more to check. -
same issue i have came across; see my post:
https://forum.qt.io/topic/122640/qvideoprobe-stop-working-when-processing-time-is-long/11