summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2014-11-27 11:52:10 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2014-11-27 11:52:10 +0900
commit777f25f20f991357acf93582471900f6b85532a1 (patch)
tree041a26f32bcf2f53249660b4cabd42c8e7a1ded2
parent01d88b2886ada398c883a44410827b11b907e512 (diff)
parent911c41c9f7a08b7fb3476954472f747365999daf (diff)
downloadtdelibs-777f25f20f991357acf93582471900f6b85532a1.tar.gz
tdelibs-777f25f20f991357acf93582471900f6b85532a1.zip
Merge branch 'master' of http://scm.trinitydesktop.org/scm/git/tdelibs
-rw-r--r--tdecore/tdehw/tdehardwaredevices.cpp11
-rw-r--r--tdecore/tdehw/tdestoragedevice.cpp20
2 files changed, 26 insertions, 5 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;
}
}
diff --git a/tdecore/tdehw/tdestoragedevice.cpp b/tdecore/tdehw/tdestoragedevice.cpp
index 9491a6675..70258e436 100644
--- a/tdecore/tdehw/tdestoragedevice.cpp
+++ b/tdecore/tdehw/tdestoragedevice.cpp
@@ -25,6 +25,7 @@
#include <sys/ioctl.h>
#include <linux/cdrom.h>
+#include <tqregexp.h>
#include <tqpixmap.h>
#include <tqfile.h>
@@ -489,13 +490,26 @@ void TDEStorageDevice::internalSetSlaveDevices(TQStringList sd) {
m_slaveDevices = sd;
}
+TQString decodeHexEncoding(TQString str) {
+ TQRegExp hexEncRegExp("\\\\x[0-9A-Fa-f]{1,2}");
+ hexEncRegExp.setMinimal(false);
+ hexEncRegExp.setCaseSensitive(true);
+ int s = -1;
+
+ while((s = hexEncRegExp.search(str, s+1))>=0){
+ str.replace(s, hexEncRegExp.cap(0).length(), TQChar((char)strtol(hexEncRegExp.cap(0).mid(2).ascii(), NULL, 16)));
+ }
+
+ return str;
+}
+
TQString TDEStorageDevice::friendlyName() {
// Return the actual storage device name
TQString devicevendorid = vendorEncoded();
TQString devicemodelid = modelEncoded();
- devicevendorid.replace("\\x20", " ");
- devicemodelid.replace("\\x20", " ");
+ devicevendorid = decodeHexEncoding(devicevendorid);
+ devicemodelid = decodeHexEncoding(devicemodelid);
devicevendorid = devicevendorid.stripWhiteSpace();
devicemodelid = devicemodelid.stripWhiteSpace();
@@ -637,7 +651,7 @@ TQPixmap TDEStorageDevice::icon(TDEIcon::StdSizes size) {
ret = DesktopIcon("tape_unmount", size);
}
if (isDiskOfType(TDEDiskDeviceType::Camera)) {
- ret = DesktopIcon("camera_unmount");
+ ret = DesktopIcon("camera_unmount", size);
}
if (isDiskOfType(TDEDiskDeviceType::HDD)) {