Allow ClassDB to create a Object without postinitialization for GDExtension.
This commit is contained in:
@ -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
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ public:
|
||||
virtual Error poll() = 0;
|
||||
virtual void close() = 0;
|
||||
|
||||
static WebRTCPeerConnection *create();
|
||||
static WebRTCPeerConnection *create(bool p_notify_postinitialize = true);
|
||||
|
||||
WebRTCPeerConnection();
|
||||
~WebRTCPeerConnection();
|
||||
|
||||
Reference in New Issue
Block a user