Skip to content

Commit a2e74eb

Browse files
Disable detection when started in local client mode
1 parent 8a88573 commit a2e74eb

3 files changed

Lines changed: 53 additions & 25 deletions

File tree

ResourceManager.cpp

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -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

357358
void 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

393410
void ResourceManager::DetectDevicesThreadFunction()

ResourceManager.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ class ResourceManager
101101

102102
void DetectDevices();
103103

104+
void DisableDetection();
105+
104106
void StopDeviceDetection();
105107

106108
void WaitForDeviceDetection();
@@ -110,6 +112,11 @@ class ResourceManager
110112

111113
static std::unique_ptr<ResourceManager> instance;
112114

115+
/*-------------------------------------------------------------------------------------*\
116+
| Detection enabled flag |
117+
\*-------------------------------------------------------------------------------------*/
118+
bool detection_enabled;
119+
113120
/*-------------------------------------------------------------------------------------*\
114121
| Profile Manager |
115122
\*-------------------------------------------------------------------------------------*/

main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ int main(int argc, char* argv[])
172172
{
173173
ResourceManager::get()->DetectDevices();
174174
}
175+
else
176+
{
177+
ResourceManager::get()->DisableDetection();
178+
}
175179
}
176180

177181
/*---------------------------------------------------------*\

0 commit comments

Comments
 (0)