frontend: fix leaving FE canvases in bad state #12728
Open
+35
−30
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR modifies the canvases vector to be
represented as a map of obs_canvas_t* to a
shared pointer to OBS::Canvas.
This will preserve both the OBS::Canvas manager
instance, and pointer to obs_canvas_t* for
reference by obs_frontend_canvas_remove(),
ensuring that the right objects will be used
when called upon.
Motivation and Context
The
obs_frontend_remove_canvas
is called, thedestructor of OBS::Canvas calls
obs_canvas_release() on an object which is
both allocated on the heap and used as reference.
This causes the
canvases
collection on the mainwindow to become corrupt, and crash the next time
you try to add another frontend canvas.
This effectively prevents the canvases collection
from being managed properly by plug-ins.
How Has This Been Tested?
Ran obs_frontend_add_canvas() followed by obs_frontend_remove_canvas() followed by obs_frontend_add_canvas() before and after the change.
Before change: crash
After change: smooth operation
Types of changes
Checklist: