Initialize to empty path if .strings.bank not loaded - #429
Conversation
There was a problem hiding this comment.
Pull request overview
Adds diagnostic logging to help users understand why FMOD objects fetched by path (e.g., buses/events) may fail at runtime when the corresponding strings bank isn’t loaded (follow-up to #428).
Changes:
- Replaces the silent
getPath(...)check inFMODCLASSWITHPATHwithERROR_CHECK_WITH_REASON(...)to emit a helpful message when path resolution fails.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| char path[MAX_PATH_SIZE]; \ | ||
| ERROR_CHECK(wrapped->getPath(path, MAX_PATH_SIZE, nullptr)); \ | ||
| ERROR_CHECK_WITH_REASON(wrapped->getPath(path, MAX_PATH_SIZE, nullptr), "Could not find path. It is likely that .strings.bank has not been loaded."); \ | ||
| ERROR_CHECK(wrapped->getID(&ref->_guid)); \ | ||
| ref->_path = String(path); \ |
There was a problem hiding this comment.
wrapped->getPath(...) can fail (e.g., when the strings bank isn’t loaded), but the return value from ERROR_CHECK_WITH_REASON(...) is currently ignored. If it fails, path remains uninitialized and ref->_path = String(path) can read garbage / run past the buffer (undefined behavior) while also continuing to populate _guid. Handle the failure explicitly (e.g., initialize path to an empty string and/or early-return an empty Ref or set _path to "" when getPath fails).
|
I noticed the PR checks timed out; I currently have I'm also not sure if you'd like me to address Copilot's review: the feedback seems to be outside of the scope of "add an error message to a pre-existing error". I'd be happy to expand scope to include more checks for the result of Let me know if there's any other concerns I can address. |
|
Hello. |
|
I think that makes sense to me. I will update this PR when I have some time to include those extra checks. |
30846f2 to
6463b7c
Compare
|
Finally had some time to test this, I improved the error checker, initialized the path with empty values (in case loading fails), and added a message which prints the |
|
Ah, and I forgot to address the feedback about moving the errors to the getter, will do so shortly |
|
So, I looked into implementing the above, and I don't think inserting errors into the getter works because of the caching system. When a bank is loaded, The cache emits warnings for the editor/debug builds when it cannot find a path from Related to this, I found a bug in Edit: Just found another similar bug in |
6463b7c to
bf4bf17
Compare
bf4bf17 to
31b595d
Compare
.strings.bank not loaded
31b595d to
92f91a7
Compare
As a follow up to #428, an error/warning message would be useful here to help people in situations like mine diagnose the problem more easily.
Since not everyone might want to load in strings, happy to make this a warning instead; also happy to move this message to more bus/event specific loading code. Let me know what would work best.