forked from qt-creator/qt-creator
Utils: Fix FileAccess if device returns nullptr
A device may return a nullptr if it does not support device access. Change-Id: I302a2c63406268a2ff876c1bf408c5e26137fd9d Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -1179,13 +1179,13 @@ DeviceFileAccess *FilePath::fileAccess() const
|
||||
static DeviceFileAccess dummy;
|
||||
const expected_str<DeviceFileAccess *> access = getFileAccess(*this);
|
||||
QTC_ASSERT_EXPECTED(access, return &dummy);
|
||||
return *access ? *access : &dummy;
|
||||
return *access;
|
||||
}
|
||||
|
||||
bool FilePath::hasFileAccess() const
|
||||
{
|
||||
const expected_str<DeviceFileAccess *> access = getFileAccess(*this);
|
||||
return access && access.value();
|
||||
return access.has_value();
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -417,12 +417,17 @@ DeviceManager::DeviceManager(bool isInstance) : d(std::make_unique<DeviceManager
|
||||
deviceHooks.fileAccess = [](const FilePath &filePath) -> expected_str<DeviceFileAccess *> {
|
||||
if (!filePath.needsDevice())
|
||||
return DesktopDeviceFileAccess::instance();
|
||||
auto device = DeviceManager::deviceForPath(filePath);
|
||||
IDevice::ConstPtr device = DeviceManager::deviceForPath(filePath);
|
||||
if (!device) {
|
||||
return make_unexpected(
|
||||
QString("No device found for path \"%1\"").arg(filePath.toUserOutput()));
|
||||
}
|
||||
return device->fileAccess();
|
||||
DeviceFileAccess *fileAccess = device->fileAccess();
|
||||
if (!fileAccess) {
|
||||
return make_unexpected(
|
||||
QString("No file access for device \"%1\"").arg(device->displayName()));
|
||||
}
|
||||
return fileAccess;
|
||||
};
|
||||
|
||||
deviceHooks.environment = [](const FilePath &filePath) -> expected_str<Environment> {
|
||||
|
||||
Reference in New Issue
Block a user