From e7091d07cdd15f9ef3c0083a02532efa2866298c Mon Sep 17 00:00:00 2001 From: zCubed3 Date: Thu, 27 Oct 2022 13:52:38 -0700 Subject: Fix OS.get_video_adapter_driver_info crash --- platform/linuxbsd/os_linuxbsd.cpp | 4 ++++ platform/windows/os_windows.cpp | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'platform') diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cpp index 995a904398..11b667fcef 100644 --- a/platform/linuxbsd/os_linuxbsd.cpp +++ b/platform/linuxbsd/os_linuxbsd.cpp @@ -246,6 +246,10 @@ String OS_LinuxBSD::get_version() const { } Vector OS_LinuxBSD::get_video_adapter_driver_info() const { + if (RenderingServer::get_singleton()->get_rendering_device() == nullptr) { + return Vector(); + } + const String rendering_device_name = RenderingServer::get_singleton()->get_rendering_device()->get_device_name(); // e.g. `NVIDIA GeForce GTX 970` const String rendering_device_vendor = RenderingServer::get_singleton()->get_rendering_device()->get_device_vendor_name(); // e.g. `NVIDIA` const String card_name = rendering_device_name.trim_prefix(rendering_device_vendor).strip_edges(); // -> `GeForce GTX 970` diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 5ca064e523..a8911788fe 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -311,6 +311,10 @@ String OS_Windows::get_version() const { } Vector OS_Windows::get_video_adapter_driver_info() const { + if (RenderingServer::get_singleton()->get_rendering_device() == nullptr) { + return Vector(); + } + REFCLSID clsid = CLSID_WbemLocator; // Unmarshaler CLSID REFIID uuid = IID_IWbemLocator; // Interface UUID IWbemLocator *wbemLocator = NULL; // to get the services -- cgit v1.2.3