From e993909bd060b2c99a90706a5191a59d4a6ee5d1 Mon Sep 17 00:00:00 2001 From: John Maguire Date: Mon, 27 Sep 2010 17:27:08 +0000 Subject: [PATCH] Fix USB mass storage devices on Mac. Fixes issue #821 --- src/devices/macdevicelister.mm | 16 +++++++++++----- src/lyrics/ultimatelyricsreader.h | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/devices/macdevicelister.mm b/src/devices/macdevicelister.mm index aa48a8b80..69bc44137 100644 --- a/src/devices/macdevicelister.mm +++ b/src/devices/macdevicelister.mm @@ -7,6 +7,7 @@ #include #include #include +#include #import #import @@ -252,8 +253,11 @@ QString GetIconForDevice(io_object_t device) { } QString GetSerialForDevice(io_object_t device) { - return QString( - "USB/" + GetUSBRegistryEntryString(device, CFSTR(kUSBSerialNumberString))); + QString serial = GetUSBRegistryEntryString(device, CFSTR(kUSBSerialNumberString)); + if (!serial.isEmpty()) { + return "USB/" + serial; + } + return QString(); } QString GetSerialForMTPDevice(io_object_t device) { @@ -308,7 +312,7 @@ void MacDeviceLister::DiskAddedCallback(DADiskRef disk, void* context) { if (volume_path) { io_object_t device = DADiskCopyIOMedia(disk); CFStringRef class_name = IOObjectCopyClass(device); - if (class_name && CFStringCompare(class_name, CFSTR(kIOUSBDeviceClassName), 0) == kCFCompareEqualTo) { + if (class_name && CFStringCompare(class_name, CFSTR(kIOMediaClass), 0) == kCFCompareEqualTo) { QString vendor = GetUSBRegistryEntryString(device, CFSTR(kUSBVendorString)); QString product = GetUSBRegistryEntryString(device, CFSTR(kUSBProductString)); @@ -320,8 +324,10 @@ void MacDeviceLister::DiskAddedCallback(DADiskRef disk, void* context) { NSDictionary* dict = (NSDictionary*)properties; if ([[dict objectForKey:@"Removable"] intValue] == 1) { QString serial = GetSerialForDevice(device); - me->current_devices_[serial] = QString(DADiskGetBSDName(disk)); - emit me->DeviceAdded(serial); + if (!serial.isEmpty()) { + me->current_devices_[serial] = QString(DADiskGetBSDName(disk)); + emit me->DeviceAdded(serial); + } } } } diff --git a/src/lyrics/ultimatelyricsreader.h b/src/lyrics/ultimatelyricsreader.h index 0b13b7710..f87b62fea 100644 --- a/src/lyrics/ultimatelyricsreader.h +++ b/src/lyrics/ultimatelyricsreader.h @@ -18,11 +18,11 @@ #define ULTIMATELYRICSREADER_H #include +#include #include "htmlscraper.h" class QIODevice; -class QXmlStreamReader; class UltimateLyricsReader : public QObject { Q_OBJECT