@@ -51,7 +51,6 @@ bool WSServer::isControlCommand(USB2SnesWS::opcode opcode)
5151 return ; \
5252}
5353
54- // TODO, need to delete req when async device list is done
5554
5655void WSServer::executeServerRequest (MRequest* req)
5756{
@@ -62,10 +61,11 @@ void WSServer::executeServerRequest(MRequest* req)
6261 case USB2SnesWS::DeviceList : {
6362 if (numberOfAsyncFactory == 0 ) {
6463 QStringList l = getDevicesList ();
64+ sInfo () << " Server request " << *req << " executed in " << req->timeCreated .msecsTo (QTime::currentTime ());
6565 sendReply (ws, l);
6666 } else {
6767 pendingDeviceListWebsocket.append (ws);
68- pendingDeviceListRequests.append (req);
68+ pendingDeviceListRequests.append (* req);
6969 if (pendingDeviceListWebsocket.size () == 1 )
7070 asyncDeviceList ();
7171 }
@@ -100,8 +100,8 @@ void WSServer::executeServerRequest(MRequest* req)
100100 if (req->opcode != USB2SnesWS::DeviceList)
101101 {
102102 sInfo () << " Server request " << *req << " executed in " << req->timeCreated .msecsTo (QTime::currentTime ());
103- delete req;
104103 }
104+ delete req;
105105}
106106
107107void WSServer::executeRequest (MRequest *req)
@@ -540,8 +540,14 @@ void WSServer::asyncDeviceList()
540540 {
541541 if (devFact->hasAsyncListDevices ())
542542 {
543- if (devFact->asyncListDevices ())
544- pendingDeviceListQuery++;
543+ pendingDeviceListQuery++;
544+ }
545+ }
546+ for (auto devFact : qAsConst (deviceFactories))
547+ {
548+ if (devFact->hasAsyncListDevices ())
549+ {
550+ devFact->asyncListDevices ();
545551 }
546552 }
547553}
@@ -551,16 +557,15 @@ void WSServer::onDeviceListDone()
551557 sDebug () << qobject_cast<DeviceFactory*>(sender ())->name () << " is done doing devicelist" ;
552558 pendingDeviceListQuery--;
553559 if (pendingDeviceListQuery != 0 )
554- return ;
560+ return ;
555561 for (auto ws : qAsConst (pendingDeviceListWebsocket))
556562 {
557563 sDebug () << " Sending device list to " << wsInfos[ws].name ;
558564 sendReply (ws, deviceList);
559565 }
560- for (MRequest* req : qAsConst ( pendingDeviceListRequests) )
566+ for (const MRequest& req : pendingDeviceListRequests)
561567 {
562- sInfo () << " Device request finished - " << *req << " processed in " << req->timeCreated .msecsTo (QTime::currentTime ()) << " ms" ;
563- delete req;
568+ sInfo () << " Device request finished - " << req << " processed in " << req.timeCreated .msecsTo (QTime::currentTime ()) << " ms" ;
564569 }
565570 pendingDeviceListQuery = 0 ;
566571 deviceList.clear ();
0 commit comments