You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-16 14:00:40 +00:00
Merge pull request #86843 from RandomShaper/fix_null_ptr
Avoid several null-dereferences of ApiContextRD
This commit is contained in:
@@ -538,9 +538,10 @@ void DisplayServerAndroid::reset_window() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (context_rd->window_create(MAIN_WINDOW_ID, last_vsync_mode, display_size.width, display_size.height, &wpd) != OK) {
|
if (context_rd->window_create(MAIN_WINDOW_ID, last_vsync_mode, display_size.width, display_size.height, &wpd) != OK) {
|
||||||
|
ERR_PRINT(vformat("Failed to reset %s window.", context_rd->get_api_name()));
|
||||||
memdelete(context_rd);
|
memdelete(context_rd);
|
||||||
context_rd = nullptr;
|
context_rd = nullptr;
|
||||||
ERR_FAIL_MSG(vformat("Failed to reset %s window.", context_rd->get_api_name()));
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -575,9 +576,10 @@ DisplayServerAndroid::DisplayServerAndroid(const String &p_rendering_driver, Dis
|
|||||||
|
|
||||||
if (context_rd) {
|
if (context_rd) {
|
||||||
if (context_rd->initialize() != OK) {
|
if (context_rd->initialize() != OK) {
|
||||||
|
ERR_PRINT(vformat("Failed to initialize %s context", context_rd->get_api_name()));
|
||||||
memdelete(context_rd);
|
memdelete(context_rd);
|
||||||
context_rd = nullptr;
|
context_rd = nullptr;
|
||||||
ERR_FAIL_MSG(vformat("Failed to initialize %s context", context_rd->get_api_name()));
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Size2i display_size = OS_Android::get_singleton()->get_display_size();
|
Size2i display_size = OS_Android::get_singleton()->get_display_size();
|
||||||
@@ -596,9 +598,10 @@ DisplayServerAndroid::DisplayServerAndroid(const String &p_rendering_driver, Dis
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (context_rd->window_create(MAIN_WINDOW_ID, p_vsync_mode, display_size.width, display_size.height, &wpd) != OK) {
|
if (context_rd->window_create(MAIN_WINDOW_ID, p_vsync_mode, display_size.width, display_size.height, &wpd) != OK) {
|
||||||
|
ERR_PRINT(vformat("Failed to create %s window.", context_rd->get_api_name()));
|
||||||
memdelete(context_rd);
|
memdelete(context_rd);
|
||||||
context_rd = nullptr;
|
context_rd = nullptr;
|
||||||
ERR_FAIL_MSG(vformat("Failed to create %s window.", context_rd->get_api_name()));
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
rendering_device = memnew(RenderingDevice);
|
rendering_device = memnew(RenderingDevice);
|
||||||
|
|||||||
@@ -87,17 +87,19 @@ DisplayServerIOS::DisplayServerIOS(const String &p_rendering_driver, WindowMode
|
|||||||
|
|
||||||
if (context_rd) {
|
if (context_rd) {
|
||||||
if (context_rd->initialize() != OK) {
|
if (context_rd->initialize() != OK) {
|
||||||
|
ERR_PRINT(vformat("Failed to initialize %s context", context_rd->get_api_name()));
|
||||||
memdelete(context_rd);
|
memdelete(context_rd);
|
||||||
context_rd = nullptr;
|
context_rd = nullptr;
|
||||||
ERR_FAIL_MSG(vformat("Failed to initialize %s context", context_rd->get_api_name()));
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Size2i size = Size2i(layer.bounds.size.width, layer.bounds.size.height) * screen_get_max_scale();
|
Size2i size = Size2i(layer.bounds.size.width, layer.bounds.size.height) * screen_get_max_scale();
|
||||||
if (context_rd->window_create(MAIN_WINDOW_ID, p_vsync_mode, size.width, size.height, &wpd) != OK) {
|
if (context_rd->window_create(MAIN_WINDOW_ID, p_vsync_mode, size.width, size.height, &wpd) != OK) {
|
||||||
|
ERR_PRINT(vformat("Failed to create %s window.", context_rd->get_api_name()));
|
||||||
memdelete(context_rd);
|
memdelete(context_rd);
|
||||||
context_rd = nullptr;
|
context_rd = nullptr;
|
||||||
r_error = ERR_UNAVAILABLE;
|
r_error = ERR_UNAVAILABLE;
|
||||||
ERR_FAIL_MSG(vformat("Failed to create %s window.", context_rd->get_api_name()));
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
rendering_device = memnew(RenderingDevice);
|
rendering_device = memnew(RenderingDevice);
|
||||||
|
|||||||
@@ -6080,10 +6080,11 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
|
|||||||
|
|
||||||
if (context_rd) {
|
if (context_rd) {
|
||||||
if (context_rd->initialize() != OK) {
|
if (context_rd->initialize() != OK) {
|
||||||
|
ERR_PRINT(vformat("Could not initialize %s", context_rd->get_api_name()));
|
||||||
memdelete(context_rd);
|
memdelete(context_rd);
|
||||||
context_rd = nullptr;
|
context_rd = nullptr;
|
||||||
r_error = ERR_CANT_CREATE;
|
r_error = ERR_CANT_CREATE;
|
||||||
ERR_FAIL_MSG(vformat("Could not initialize %s", context_rd->get_api_name()));
|
return;
|
||||||
}
|
}
|
||||||
driver_found = true;
|
driver_found = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4625,10 +4625,11 @@ DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (context_rd->window_create(id, p_vsync_mode, WindowRect.right - WindowRect.left, WindowRect.bottom - WindowRect.top, &wpd) != OK) {
|
if (context_rd->window_create(id, p_vsync_mode, WindowRect.right - WindowRect.left, WindowRect.bottom - WindowRect.top, &wpd) != OK) {
|
||||||
|
ERR_PRINT(vformat("Failed to create %s Window.", context_rd->get_api_name()));
|
||||||
memdelete(context_rd);
|
memdelete(context_rd);
|
||||||
context_rd = nullptr;
|
context_rd = nullptr;
|
||||||
windows.erase(id);
|
windows.erase(id);
|
||||||
ERR_FAIL_V_MSG(INVALID_WINDOW_ID, vformat("Failed to create %s Window.", context_rd->get_api_name()));
|
return INVALID_WINDOW_ID;
|
||||||
}
|
}
|
||||||
wd.context_created = true;
|
wd.context_created = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user