Skip to content

Conversation

zavitax
Copy link
Contributor

@zavitax zavitax commented Oct 13, 2025

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, the
destructor 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 main
window 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

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

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

@zavitax zavitax force-pushed the frontend_canvas_remove_fix branch 2 times, most recently from b54e53c to e1734c5 Compare October 13, 2025 13:25
The `obs_frontend_remove_canvas` is called, the
destructor 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 main
window to become corrupt, and crash the next time
you try to add another frontend canvas.

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.
@zavitax zavitax force-pushed the frontend_canvas_remove_fix branch from e1734c5 to f460a38 Compare October 13, 2025 13:31
@Warchamp7 Warchamp7 requested review from PatTheMav and derrod October 13, 2025 14:29
@Warchamp7 Warchamp7 added the Bug Fix Non-breaking change which fixes an issue label Oct 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Fix Non-breaking change which fixes an issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants