summaryrefslogtreecommitdiffstats
path: root/tdecore/tdehw/tdestoragedevice.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2014-11-26 00:09:45 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2014-11-26 00:09:45 -0600
commit3b57fe6816f2a5837b3879e46b7286bf8d8c162c (patch)
treec716cceac9f4eed419e35bbbde37314707683b77 /tdecore/tdehw/tdestoragedevice.cpp
parent9ea35022d237e93f456d8649725ce1c52c2b61e9 (diff)
downloadtdelibs-3b57fe6816f2a5837b3879e46b7286bf8d8c162c.tar.gz
tdelibs-3b57fe6816f2a5837b3879e46b7286bf8d8c162c.zip
Fix hardware control center crashes on device hot remove
Fix incorrect decoding of hex escaped device names
Diffstat (limited to 'tdecore/tdehw/tdestoragedevice.cpp')
-rw-r--r--tdecore/tdehw/tdestoragedevice.cpp20
1 files changed, 17 insertions, 3 deletions
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)) {