@@ -37,6 +37,7 @@ ResourceManager::ResourceManager()
3737 /* -------------------------------------------------------------------------*\
3838 | Initialize Detection Variables |
3939 \*-------------------------------------------------------------------------*/
40+ detection_enabled = true ;
4041 detection_percent = 100 ;
4142 detection_string = " " ;
4243 detection_is_required = false ;
@@ -356,38 +357,54 @@ void ResourceManager::Cleanup()
356357
357358void ResourceManager::DetectDevices ()
358359{
359- /* -------------------------------------------------*\
360- | Do nothing is it is already detecting devices |
361- \*-------------------------------------------------*/
362- if (detection_is_required.load ())
360+ if (detection_enabled)
363361 {
364- return ;
365- }
362+ /* -------------------------------------------------*\
363+ | Do nothing is it is already detecting devices |
364+ \*-------------------------------------------------*/
365+ if (detection_is_required.load ())
366+ {
367+ return ;
368+ }
366369
367- /* -------------------------------------------------*\
368- | If there's anything left from the last time, |
369- | we shall remove it first |
370- \*-------------------------------------------------*/
371- detection_percent = 0 ;
372- detection_string = " " ;
370+ /* -------------------------------------------------*\
371+ | If there's anything left from the last time, |
372+ | we shall remove it first |
373+ \*-------------------------------------------------*/
374+ detection_percent = 0 ;
375+ detection_string = " " ;
373376
374- DetectionProgressChanged ();
377+ DetectionProgressChanged ();
375378
376- Cleanup ();
379+ Cleanup ();
377380
378- DeviceListChanged ();
381+ DeviceListChanged ();
379382
380- /* -------------------------------------------------*\
381- | Start the device detection thread |
382- \*-------------------------------------------------*/
383- detection_is_required = true ;
384- DetectDevicesThread = new std::thread (&ResourceManager::DetectDevicesThreadFunction, this );
383+ /* -------------------------------------------------*\
384+ | Start the device detection thread |
385+ \*-------------------------------------------------*/
386+ detection_is_required = true ;
387+ DetectDevicesThread = new std::thread (&ResourceManager::DetectDevicesThreadFunction, this );
385388
386- /* -------------------------------------------------*\
387- | Release the current thread to allow detection |
388- | thread to start |
389- \*-------------------------------------------------*/
390- std::this_thread::sleep_for (1ms);
389+ /* -------------------------------------------------*\
390+ | Release the current thread to allow detection |
391+ | thread to start |
392+ \*-------------------------------------------------*/
393+ std::this_thread::sleep_for (1ms);
394+ }
395+ else
396+ {
397+ /* -------------------------------------------------*\
398+ | Signal that detection is complete |
399+ \*-------------------------------------------------*/
400+ detection_percent = 100 ;
401+ DetectionProgressChanged ();
402+ }
403+ }
404+
405+ void ResourceManager::DisableDetection ()
406+ {
407+ detection_enabled = false ;
391408}
392409
393410void ResourceManager::DetectDevicesThreadFunction ()
0 commit comments