Well, It works almost fine, but there's still a (little) issue :
First : here is a sample code of my getChannelListNOW() function:
IRCChannelDict& IRCServer::getChannelListNOW() {
_channelListUpdateOk = false;
sendLineThruSocket("LIST");
while(!_channelListUpdateOk) {
}
return _channelDict;
}
// _channelListUpdateOk is set to true by the socket message parser
// when it detects the end of the channel's list transmission.
IRCChannelDict& IRCServer::getChannelListNOW() {
_channelListUpdateOk = false;
sendLineThruSocket("LIST");
while(!_channelListUpdateOk) {
QApplication::eventLoop()->processEvents(QEventLoop::AllEvents);
}
return _channelDict;
}
// _channelListUpdateOk is set to true by the socket message parser
// when it detects the end of the channel's list transmission.
To copy to clipboard, switch view to plain text mode
Another similar function is getTimeOfServerNOW().
In my interface, i've got two buttons connected to two main window's slots in order to make a call of those functions.
I tried to click very fast on getTimeOfServer and immediatly after on getChannelList.
As the getTimeOfServerNOW is much quicker (less than 500ms), It should respond BEFORE getChannelListNOW() (2 or 3 seconds).
But it don't : in this test, I get the opposite : TimeOfServer respond AFTER ChannelList.
I think it's due to the call stack (see below), the first while statement can't be reached until getChannelListNOW() has ended.
onGetTimeOfServer() // slot called by the appropriate button.
getTimeOfServer() (#1)
while (!finished) processEvents() // inside getTimeOfServer() func
onGetChannelList() slot called inside 'processEvent'
getChannelListNOW() (#3)
while (!finished2) processEvents() (#4)
onGetTimeOfServer() // slot called by the appropriate button.
getTimeOfServer() (#1)
while (!finished) processEvents() // inside getTimeOfServer() func
onGetChannelList() slot called inside 'processEvent'
getChannelListNOW() (#3)
while (!finished2) processEvents() (#4)
To copy to clipboard, switch view to plain text mode
In other words, if more than one such request is called at a time, all the request will return only when the longest one has finished. This is not really a big problem for me, but do you have an idea on how to bypass this problem ?
Anyway, many thanks for your 'event' tip
Bookmarks