summaryrefslogtreecommitdiffstats
path: root/tdecore/tdehw/tdehardwaredevices.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tdecore/tdehw/tdehardwaredevices.cpp')
-rw-r--r--tdecore/tdehw/tdehardwaredevices.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/tdecore/tdehw/tdehardwaredevices.cpp b/tdecore/tdehw/tdehardwaredevices.cpp
index 8905b6000..fd8ee3ba5 100644
--- a/tdecore/tdehw/tdehardwaredevices.cpp
+++ b/tdecore/tdehw/tdehardwaredevices.cpp
@@ -402,8 +402,8 @@ void TDEHardwareDevices::processHotPluggedHardware() {
TDEGenericDevice *hwdevice;
for (hwdevice = m_deviceList.first(); hwdevice; hwdevice = m_deviceList.next()) {
if (hwdevice->systemPath() == systempath) {
- emit hardwareRemoved(hwdevice);
- emit hardwareEvent(TDEHardwareEvent::HardwareRemoved, hwdevice->uniqueID());
+ // Temporarily disable auto-deletion to ensure object validity when calling the Removed events below
+ m_deviceList.setAutoDelete(false);
// If the device is a storage device and has a slave, update it as well
if (hwdevice->type() == TDEGenericDeviceType::Disk) {
@@ -423,6 +423,13 @@ void TDEHardwareDevices::processHotPluggedHardware() {
m_deviceList.remove(hwdevice);
}
+ emit hardwareRemoved(hwdevice);
+ emit hardwareEvent(TDEHardwareEvent::HardwareRemoved, hwdevice->uniqueID());
+
+ // Reenable auto-deletion and delete the removed device object
+ m_deviceList.setAutoDelete(true);
+ delete hwdevice;
+
break;
}
}