MacOsDeviceLister: Replace BOOST_SCOPE_EXIT with QScopeGuard
This commit is contained in:
parent
4ef3f3568d
commit
7d5c7f8493
|
@ -19,8 +19,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <boost/scope_exit.hpp>
|
|
||||||
|
|
||||||
#include <libmtp.h>
|
#include <libmtp.h>
|
||||||
|
|
||||||
#include <CoreFoundation/CFRunLoop.h>
|
#include <CoreFoundation/CFRunLoop.h>
|
||||||
|
@ -37,6 +35,7 @@
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
#include <QScopeGuard>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "macosdevicelister.h"
|
#include "macosdevicelister.h"
|
||||||
|
@ -491,10 +490,7 @@ void MacOsDeviceLister::USBDeviceAddedCallback(void *refcon, io_iterator_t it) {
|
||||||
io_object_t object;
|
io_object_t object;
|
||||||
while ((object = IOIteratorNext(it))) {
|
while ((object = IOIteratorNext(it))) {
|
||||||
ScopedCFTypeRef<CFStringRef> class_name(IOObjectCopyClass(object));
|
ScopedCFTypeRef<CFStringRef> class_name(IOObjectCopyClass(object));
|
||||||
BOOST_SCOPE_EXIT((object)) {
|
const QScopeGuard io_object_release = qScopeGuard([object]() { IOObjectRelease(object); });
|
||||||
IOObjectRelease(object);
|
|
||||||
}
|
|
||||||
BOOST_SCOPE_EXIT_END
|
|
||||||
|
|
||||||
if (CFStringCompare(class_name.get(), CFSTR(kIOUSBDeviceClassName), 0) == kCFCompareEqualTo) {
|
if (CFStringCompare(class_name.get(), CFSTR(kIOUSBDeviceClassName), 0) == kCFCompareEqualTo) {
|
||||||
NSString *vendor = reinterpret_cast<NSString*>(GetPropertyForDevice(object, CFSTR(kUSBVendorString)));
|
NSString *vendor = reinterpret_cast<NSString*>(GetPropertyForDevice(object, CFSTR(kUSBVendorString)));
|
||||||
|
@ -573,11 +569,10 @@ void MacOsDeviceLister::USBDeviceAddedCallback(void *refcon, io_iterator_t it) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Automatically close & release usb device at scope exit.
|
// Automatically close & release usb device at scope exit.
|
||||||
BOOST_SCOPE_EXIT((dev)) {
|
const QScopeGuard dev_close_release = qScopeGuard([dev]() {
|
||||||
(*dev)->USBDeviceClose(dev);
|
(*dev)->USBDeviceClose(dev);
|
||||||
(*dev)->Release(dev);
|
(*dev)->Release(dev);
|
||||||
}
|
});
|
||||||
BOOST_SCOPE_EXIT_END
|
|
||||||
|
|
||||||
// Request the string descriptor at 0xee.
|
// Request the string descriptor at 0xee.
|
||||||
// This is a magic string that indicates whether this device supports MTP.
|
// This is a magic string that indicates whether this device supports MTP.
|
||||||
|
@ -629,8 +624,7 @@ void MacOsDeviceLister::USBDeviceRemovedCallback(void *refcon, io_iterator_t it)
|
||||||
io_object_t object;
|
io_object_t object;
|
||||||
while ((object = IOIteratorNext(it))) {
|
while ((object = IOIteratorNext(it))) {
|
||||||
ScopedCFTypeRef<CFStringRef> class_name(IOObjectCopyClass(object));
|
ScopedCFTypeRef<CFStringRef> class_name(IOObjectCopyClass(object));
|
||||||
BOOST_SCOPE_EXIT((object)) { IOObjectRelease(object); }
|
const QScopeGuard io_object_release = qScopeGuard([object]() { IOObjectRelease(object); });
|
||||||
BOOST_SCOPE_EXIT_END
|
|
||||||
|
|
||||||
if (CFStringCompare(class_name.get(), CFSTR(kIOUSBDeviceClassName), 0) == kCFCompareEqualTo) {
|
if (CFStringCompare(class_name.get(), CFSTR(kIOUSBDeviceClassName), 0) == kCFCompareEqualTo) {
|
||||||
NSString *vendor = reinterpret_cast<NSString*>(GetPropertyForDevice(object, CFSTR(kUSBVendorString)));
|
NSString *vendor = reinterpret_cast<NSString*>(GetPropertyForDevice(object, CFSTR(kUSBVendorString)));
|
||||||
|
|
Loading…
Reference in New Issue