Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash on texture load with missing/empty resources #448

Merged
merged 2 commits into from
Feb 19, 2024

Conversation

mckinlee
Copy link
Contributor

Ran into a crash when the game tried to load textures from resources that were either missing or had empty data. Added quick checks to exit early in Gui::LoadTextureFromRawImage if the resource or its buffer is null or empty. This stops the crash and logs an error instead. Per Archez, I needed to regenerate my soh.otr via the cmake target. The recent input viewer changes add some new images that use this method, but these new checks should help avoid similar issues in the future.

crash log.txt

Ran into a crash when the game tried to load textures from resources that were either missing or had empty data. Added quick checks to exit early in `Gui::LoadTextureFromRawImage` if the resource or its buffer is null or empty. This stops the crash and logs an error instead. Should help avoid similar issues in the future.
@@ -232,6 +232,11 @@ void Gui::ImGuiBackendInit() {
void Gui::LoadTextureFromRawImage(const std::string& name, const std::string& path) {
const auto res = Context::GetInstance()->GetResourceManager()->GetArchiveManager()->LoadFileRaw(path);

if (!res || !res->Buffer || res->Buffer->empty()) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you separate out the buffer check from the res == null check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you separate out the buffer check from the res == null check?

Yeh, no problem. Check out the latest commit.

Copy link
Owner

@Kenix3 Kenix3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thankyou, looks good.

@Kenix3 Kenix3 merged commit 18ebff9 into Kenix3:main Feb 19, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants