Skip to content

Make GDVIRTUAL Binding of _instantiate_playback non-const#112591

Open
vivi512 wants to merge 1 commit intogodotengine:masterfrom
vivi512:fix-112588
Open

Make GDVIRTUAL Binding of _instantiate_playback non-const#112591
vivi512 wants to merge 1 commit intogodotengine:masterfrom
vivi512:fix-112588

Conversation

@vivi512
Copy link

@vivi512 vivi512 commented Nov 9, 2025

Fixes #112588 :

The GDVIRTUAL binding of the _instantiate_playback function of AudioStream marked it as const, when the actual function is non-const, making it impossible to override properly when using cpp bindings.

Binding (Incorrectly marked as const) :

GDVIRTUAL0RC_REQUIRED(Ref<AudioStreamPlayback>, _instantiate_playback)

Function(Non-const) :

virtual Ref<AudioStreamPlayback> instantiate_playback();

This PR fixes it (and the associated docs)

@vivi512 vivi512 requested review from a team as code owners November 9, 2025 16:42
@Mickeon
Copy link
Member

Mickeon commented Nov 9, 2025

It may not seem like it but this requires proper handling because it technically breaks compatibility. See https://docs.godotengine.org/en/stable/engine_details/development/handling_compatibility_breakages.html .

Although, one could genuinely argue that because the function was never really... functioning as intended, the breakage is completely fine.

@dsnopek
Copy link
Contributor

dsnopek commented Nov 10, 2025

It shouldn't be too hard to add a compatibility method and not cause any breakage.

Are we really sure that no one is currently using this? It would be awkward, but folks could be using the current virtual function and casting const away from this:

Ref<AudioStreamPlayback> MyClass::_instantiate_playback() const {
  return const_cast<MyClass *>(this)->_instantiate_playback_nonconst();
}

@Repiteo Repiteo modified the milestones: 4.6, 4.x Jan 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AudioStream's "_instantiate_playback" is incorrectly marked as const in the GDVIRTUAL binding

4 participants