Index: sources/device/DeviceController.cpp =================================================================== diff -u -r80b5e8f1ebb90c03c37d90d90cd2da3bd95d6803 -rb012c6d1d980d4341faad8719dd33a0bed49b7f8 --- sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision 80b5e8f1ebb90c03c37d90d90cd2da3bd95d6803) +++ sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision b012c6d1d980d4341faad8719dd33a0bed49b7f8) @@ -63,6 +63,12 @@ initConnections(); startTimer(_interval); + // Add watch for event driven detection of USB insertion/removal + doAddDirectoryWatch(Storage::USB_Dev_Path); + + // Do initial mount check on start-up + usbCheck(); + return true; } @@ -107,6 +113,8 @@ connect(&_fileSystemWatcher , SIGNAL( fileChanged(const QString &)), this , SLOT( onWatchFileChanged(const QString &))); + connect(&_fileSystemWatcher , SIGNAL( directoryChanged(const QString &)), + this , SLOT( onWatchDirectoryChanged(const QString &))); connect(&_ApplicationController , SIGNAL(didPOSTEthernetData (const QString &)), this , SLOT( onPOSTEthernetData (const QString &))); @@ -187,6 +195,7 @@ vDevice = device; return true; // application is deciding on the first existing drive } + device = ""; } vDevice = device; return false; @@ -229,11 +238,10 @@ * \details This event handler has been re-implemented in here * to receive timer events for the object * for the timer which has been set to _checkInterval - * Runs the usbCheck on interval */ void DeviceController::timerEvent(QTimerEvent *) { - usbCheck(); + // DO NOT run usbCheck() on interval to avoid performance impact since models are regenerated sdcardSpaceCheck(); } @@ -244,17 +252,16 @@ */ void DeviceController::usbCheck() { - QString device = ""; - usbSpaceCheck(); - if (usbSeek(device)) { - if (! _umounted ) { // avoid to mount the USB which has just been unmounted - usbMount(device); - } else { // the umount is requested? - usbUmount(USB_Mount_Point); - } + QString currentUSBDevice; + bool found = usbSeek(currentUSBDevice); + //DEBUG: qDebug()<< "Current usb device found " <