diff options
| author | Carl Hetherington <cth@carlh.net> | 2024-09-03 17:53:24 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2024-09-03 17:55:19 +0200 |
| commit | 5db3eda9c6f0d6b027263c519000997677253504 (patch) | |
| tree | aabeab74d8106113610b82bff6a6d60486a61412 | |
| parent | 5cbecec37e691976b8855a923a7115e7a974dd3b (diff) | |
Fix confusion about operator bool() with optional.
I think previously no exception would be thrown even if the file weren't
open.
| -rw-r--r-- | src/lib/file_group.cc | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/lib/file_group.cc b/src/lib/file_group.cc index 228faa74d..469d07702 100644 --- a/src/lib/file_group.cc +++ b/src/lib/file_group.cc @@ -84,11 +84,13 @@ FileGroup::ensure_open_path (size_t p) const _current_file->close(); } - _current_path = p; - _current_file = dcp::File(_paths[_current_path], "rb"); - if (!_current_file) { - throw OpenFileError (_paths[_current_path], errno, OpenFileError::READ); + auto file = dcp::File(_paths[_current_path], "rb"); + if (!file) { + throw OpenFileError(_paths[_current_path], errno, OpenFileError::READ); } + + _current_path = p; + _current_file = std::move(file); _current_size = dcp::filesystem::file_size(_paths[_current_path]); } |
