From 75a53d0b36174d0cfa29b6278908a55efe373e21 Mon Sep 17 00:00:00 2001 From: John Maguire Date: Thu, 11 Aug 2011 21:43:00 +0200 Subject: [PATCH] Detect CD removal on mac. --- src/devices/macdevicelister.mm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/devices/macdevicelister.mm b/src/devices/macdevicelister.mm index 6019f4115..dde8db20f 100644 --- a/src/devices/macdevicelister.mm +++ b/src/devices/macdevicelister.mm @@ -382,9 +382,16 @@ void MacDeviceLister::DiskRemovedCallback(DADiskRef disk, void* context) { MacDeviceLister* me = reinterpret_cast(context); // We cannot access the USB tree when the disk is removed but we still get // the BSD disk name. + + QString bsd_name = QString::fromAscii(DADiskGetBSDName(disk)); + if (me->cd_devices_.remove(bsd_name)) { + emit me->DeviceRemoved(bsd_name); + return; + } + for (QMap::iterator it = me->current_devices_.begin(); it != me->current_devices_.end(); ++it) { - if (it.value() == QString::fromLocal8Bit(DADiskGetBSDName(disk))) { + if (it.value() == bsd_name) { emit me->DeviceRemoved(it.key()); me->current_devices_.erase(it); break; @@ -711,6 +718,11 @@ QVariantList MacDeviceLister::DeviceIcons(const QString& serial) { if (IsMTPSerial(serial)) { return QVariantList(); } + + if (IsCDDevice(serial)) { + return QVariantList() << "media-optical"; + } + QString bsd_name = current_devices_[serial]; DASessionRef session = DASessionCreate(kCFAllocatorDefault); DADiskRef disk = DADiskCreateFromBSDName(