Skip to content

Commit c3a8308

Browse files
committed
Loader: small exception safety tweak.
Cannot use make_unique because we are using a private constructor, but the same reasoning applies.
1 parent 992e755 commit c3a8308

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

changes/sdk/mr.3475.gl.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
- pr.413.gh.OpenXR-SDK-Source
3+
---
4+
Improvement: Loader: Code cleanup and robustness improvements.

src/loader/api_layer_interface.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,10 @@ XrResult ApiLayerInterface::LoadApiLayers(const std::string& openxr_command, uin
422422
}
423423

424424
// Add this API layer to the vector
425-
api_layer_interfaces.emplace_back(new ApiLayerInterface(manifest_file->LayerName(), layer_library, supported_extensions,
426-
api_layer_info.getInstanceProcAddr,
427-
api_layer_info.createApiLayerInstance));
425+
std::unique_ptr<ApiLayerInterface> iface{new ApiLayerInterface(manifest_file->LayerName(), layer_library,
426+
supported_extensions, api_layer_info.getInstanceProcAddr,
427+
api_layer_info.createApiLayerInstance)};
428+
api_layer_interfaces.emplace_back(std::move(iface));
428429

429430
// If we load one, clear all errors.
430431
any_loaded = true;

src/loader/manifest_file.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,8 @@ void RuntimeManifestFile::CreateIfValid(const Json::Value &root_node, const std:
638638
}
639639

640640
// Add this runtime manifest file
641-
manifest_files.emplace_back(new RuntimeManifestFile(filename, lib_path));
641+
std::unique_ptr<RuntimeManifestFile> manifest{new RuntimeManifestFile(filename, lib_path)};
642+
manifest_files.emplace_back(std::move(manifest));
642643

643644
// Add any extensions to it after the fact, while handling any renamed functions
644645
manifest_files.back()->ParseCommon(runtime_root_node);
@@ -891,8 +892,9 @@ void ApiLayerManifestFile::CreateIfValid(ManifestFileType type, const std::strin
891892
}
892893

893894
// Add this layer manifest file
894-
manifest_files.emplace_back(
895-
new ApiLayerManifestFile(type, filename, layer_name, description, api_version, implementation_version, library_path));
895+
std::unique_ptr<ApiLayerManifestFile> manifest{
896+
new ApiLayerManifestFile(type, filename, layer_name, description, api_version, implementation_version, library_path)};
897+
manifest_files.emplace_back(std::move(manifest));
896898

897899
// Add any extensions to it after the fact, while handling any renamed functions
898900
manifest_files.back()->ParseCommon(layer_root_node);

0 commit comments

Comments
 (0)