diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-08-26 10:51:17 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-08-26 10:51:17 +0200 |
commit | b4f268fae891be7afb6ab04eb9405d48e3c20782 (patch) | |
tree | e1530ec365311a550a5f678233cc940fa01dd99f /modules/webrtc/webrtc_peer_connection.cpp | |
parent | e63e8453da2ef7d90f693244d8a3041466dc2c63 (diff) | |
parent | 3d575801cef4239b120e8ca974ad478a71517fdf (diff) | |
download | redot-engine-b4f268fae891be7afb6ab04eb9405d48e3c20782.tar.gz |
Merge pull request #91018 from Daylily-Zeleen/daylily-zeleen/optionally_postinitialization_for_extension_owner
Allow ClassDB to create a Object without postinitialization for GDExtension.
Diffstat (limited to 'modules/webrtc/webrtc_peer_connection.cpp')
-rw-r--r-- | modules/webrtc/webrtc_peer_connection.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/modules/webrtc/webrtc_peer_connection.cpp b/modules/webrtc/webrtc_peer_connection.cpp index 0a50b677c4..69be873fcf 100644 --- a/modules/webrtc/webrtc_peer_connection.cpp +++ b/modules/webrtc/webrtc_peer_connection.cpp @@ -43,15 +43,20 @@ void WebRTCPeerConnection::set_default_extension(const StringName &p_extension) default_extension = StringName(p_extension, true); } -WebRTCPeerConnection *WebRTCPeerConnection::create() { +WebRTCPeerConnection *WebRTCPeerConnection::create(bool p_notify_postinitialize) { #ifdef WEB_ENABLED - return memnew(WebRTCPeerConnectionJS); + return static_cast<WebRTCPeerConnection *>(ClassDB::creator<WebRTCPeerConnectionJS>(p_notify_postinitialize)); #else if (default_extension == StringName()) { WARN_PRINT_ONCE("No default WebRTC extension configured."); - return memnew(WebRTCPeerConnectionExtension); + return static_cast<WebRTCPeerConnection *>(ClassDB::creator<WebRTCPeerConnectionExtension>(p_notify_postinitialize)); + } + Object *obj = nullptr; + if (p_notify_postinitialize) { + obj = ClassDB::instantiate(default_extension); + } else { + obj = ClassDB::instantiate_without_postinitialization(default_extension); } - Object *obj = ClassDB::instantiate(default_extension); return Object::cast_to<WebRTCPeerConnectionExtension>(obj); #endif } |