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(C++ Mods): Delayed mod constructor until imgui is initialized #481

Merged
merged 1 commit into from
Apr 22, 2024

Conversation

UE4SS
Copy link
Collaborator

@UE4SS UE4SS commented Apr 21, 2024

Description

This only happens if the mod uses UE4SS_ENABLE_IMGU' macro in the constructor.

The purpose of this is to guarantee that imgui context has been set before a mod uses any imgui functions. Previously, we were assuming that the context would be set by the time the mod construct was called, however this was actually a race condition. It was possible for the mod constructor to be called before the UI code in UE4SS created the imgui context.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

See #469

Checklist

Please delete options that are not relevant. Update the list as the PR progresses.

  • I have commented my code, particularly in hard-to-understand areas.
  • I have added the necessary description of this PR to the changelog, and I have followed the same format as other entries.

@UE4SS UE4SS marked this pull request as draft April 22, 2024 09:28
@UE4SS UE4SS marked this pull request as ready for review April 22, 2024 09:30
@UE4SS UE4SS marked this pull request as draft April 22, 2024 09:33
@UE4SS
Copy link
Collaborator Author

UE4SS commented Apr 22, 2024

I've realized this fix isn't sufficient.
It will cause loading to stop if the GUI isn't enabled & visible on startup.
Will fix this soon.

@UE4SS
Copy link
Collaborator Author

UE4SS commented Apr 22, 2024

The proper fix will probably involve introducing on_ui_init for C++ mods.
That will be the place where a C++ mod uses the UE4SS_ENABLE_IMGUI macro.

This only happens if the mod uses 'UE4SS_ENABLE_IMGUI' macro in the constructor, which is no longer supported, you should use the new 'on_ui_init' instead.

The purpose of this is to guarantee that imgui context has been set before a mod uses any imgui functions.
Previously, we were assuming that the context would be set by the time the mod construct was called, however this was actually a race condition.
It was possible for the mod constructor to be called before the UI code in UE4SS created the imgui context.
@UE4SS UE4SS marked this pull request as ready for review April 22, 2024 13:13
@UE4SS
Copy link
Collaborator Author

UE4SS commented Apr 22, 2024

This is now ready.

@narknon narknon merged commit 5c9c069 into main Apr 22, 2024
@narknon narknon deleted the imgui-mod-context-fix branch April 22, 2024 17:01
trumank added a commit to trumank/kismet-debugger that referenced this pull request Apr 26, 2024
narknon added a commit that referenced this pull request May 30, 2024
Co-authored-by: Truman Kilen <t@kilen.me>

#481
narknon added a commit that referenced this pull request May 30, 2024
Co-authored-by: Truman Kilen <t@kilen.me>

#481
narknon added a commit that referenced this pull request May 30, 2024
Co-authored-by: Truman Kilen <t@kilen.me>
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