QElapsedTimer issue : code works on LINUX but not on MAC OS
-
Hi,
Yes the delay never returns or the condition to stop the loop is never TRUE : "while( timer.elapsed() < millisecondsToWait ) "
The application receives MIDI messages (it has ask for) from a MIDI deveice. If the timer is not put in some of the MIDI messages are received/processes after the end of the initialization() function. On Linux the same code works fine. Since receiving these MIDI messages triggers the display of a QDialog, the timer is there to avoid calling that dialog during the initialization phase.
Thanks for taking interest in my problem. A friend with experience in Qt says it is likely that since the timing functions are closely associated the OS it is not too surprising that there is a difference in behavior. I look on the WEB for people reporting similar problems but did not find anything.
-
While it's strange, I wouldn't make the success of the initialization based on such a timer.
I'd rather have a signal telling the initialization is done once you received the MIDI message(s) you need. Then you can trigger the next step of your application.
-
Aren't you waiting on a set of known messages ?
-
You can write an initializer class that does only this and once done the messages are routed to your usual class.
-
Not so sure what you mean. Had a look on the WEB but did not find much.
The things is the MIDI reception is triggered by the MIDI lib (RTMIDI) when is callback the function it is setup to call back (MIDIcallback) and this function is not part of a class. So I would immagine that having an initializer class implies that having this MIDIcallback function inside that class. Just guessing here. -
You can pass anything you want in the userData parameter so you could use that to pass a custom Midi message handler.
In that handler you'll check the message that you receive and once you got all the initialization messages you can emit something like a "initialized" signal and then process the rest of the message normally.
-
You can pass a custom struct that contains all the pointers to objects you need.
-
True. I though about it at one point but didn't want to bother with it at the time ... I might just have to do that.
Thanks a lot for all your help.
But in the end, it seems the initial problem ( delay() not returning ) might be specific to Qt5.5.1 on mac. I will try it out with Qt5.6. Who knows it might work. ;)