MacOsDeviceLister: Replace BOOST_SCOPE_EXIT with QScopeGuard

This commit is contained in:
Jonas Kvinge 2023-08-03 17:36:56 +02:00
parent 4ef3f3568d
commit 7d5c7f8493
1 changed files with 5 additions and 11 deletions

View File

@ -19,8 +19,6 @@
*
*/
#include <boost/scope_exit.hpp>
#include <libmtp.h>
#include <CoreFoundation/CFRunLoop.h>
@ -37,6 +35,7 @@
#include <QStringList>
#include <QUrlQuery>
#include <QUrl>
#include <QScopeGuard>
#include "config.h"
#include "macosdevicelister.h"
@ -491,10 +490,7 @@ void MacOsDeviceLister::USBDeviceAddedCallback(void *refcon, io_iterator_t it) {
io_object_t object;
while ((object = IOIteratorNext(it))) {
ScopedCFTypeRef<CFStringRef> class_name(IOObjectCopyClass(object));
BOOST_SCOPE_EXIT((object)) {
IOObjectRelease(object);
}
BOOST_SCOPE_EXIT_END
const QScopeGuard io_object_release = qScopeGuard([object]() { IOObjectRelease(object); });
if (CFStringCompare(class_name.get(), CFSTR(kIOUSBDeviceClassName), 0) == kCFCompareEqualTo) {
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.
BOOST_SCOPE_EXIT((dev)) {
const QScopeGuard dev_close_release = qScopeGuard([dev]() {
(*dev)->USBDeviceClose(dev);
(*dev)->Release(dev);
}
BOOST_SCOPE_EXIT_END
});
// Request the string descriptor at 0xee.
// 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;
while ((object = IOIteratorNext(it))) {
ScopedCFTypeRef<CFStringRef> class_name(IOObjectCopyClass(object));
BOOST_SCOPE_EXIT((object)) { IOObjectRelease(object); }
BOOST_SCOPE_EXIT_END
const QScopeGuard io_object_release = qScopeGuard([object]() { IOObjectRelease(object); });
if (CFStringCompare(class_name.get(), CFSTR(kIOUSBDeviceClassName), 0) == kCFCompareEqualTo) {
NSString *vendor = reinterpret_cast<NSString*>(GetPropertyForDevice(object, CFSTR(kUSBVendorString)));