浏览代码

libobs-winrt: Stronger exception handling

Exceptions were still leaking through somehow.
jpark37 5 年之前
父节点
当前提交
36b7ac432d
共有 1 个文件被更改,包括 18 次插入3 次删除
  1. 18 3
      libobs-winrt/winrt-capture.cpp

+ 18 - 3
libobs-winrt/winrt-capture.cpp

@@ -18,10 +18,14 @@ try {
 	return winrt::Windows::Foundation::Metadata::ApiInformation::
 		IsApiContractPresent(L"Windows.Foundation.UniversalApiContract",
 				     8);
-} catch (winrt::hresult_error &err) {
+} catch (const winrt::hresult_error &err) {
 	blog(LOG_ERROR, "winrt_capture_supported (0x%08X): %ls", err.to_abi(),
 	     err.message().c_str());
 	return false;
+} catch (...) {
+	blog(LOG_ERROR, "winrt_capture_supported (0x%08X)",
+	     winrt::to_hresult());
+	return false;
 }
 
 extern "C" EXPORT BOOL winrt_capture_cursor_toggle_supported()
@@ -34,10 +38,14 @@ try {
 #else
 	return false;
 #endif
-} catch (winrt::hresult_error &err) {
+} catch (const winrt::hresult_error &err) {
 	blog(LOG_ERROR, "winrt_capture_cursor_toggle_supported (0x%08X): %ls",
 	     err.to_abi(), err.message().c_str());
 	return false;
+} catch (...) {
+	blog(LOG_ERROR, "winrt_capture_cursor_toggle_supported (0x%08X)",
+	     winrt::to_hresult());
+	return false;
 }
 
 template<typename T>
@@ -353,6 +361,10 @@ try {
 		blog(LOG_ERROR, "CreateForWindow (0x%08X): %ls", err.to_abi(),
 		     err.message().c_str());
 		return nullptr;
+	} catch (...) {
+		blog(LOG_ERROR, "CreateForWindow (0x%08X)",
+		     winrt::to_hresult());
+		return nullptr;
 	}
 
 	const winrt::Windows::Graphics::DirectX::Direct3D11::IDirect3DDevice
@@ -406,10 +418,13 @@ try {
 
 	return capture;
 
-} catch (winrt::hresult_error &err) {
+} catch (const winrt::hresult_error &err) {
 	blog(LOG_ERROR, "winrt_capture_init (0x%08X): %ls", err.to_abi(),
 	     err.message().c_str());
 	return nullptr;
+} catch (...) {
+	blog(LOG_ERROR, "winrt_capture_init (0x%08X)", winrt::to_hresult());
+	return nullptr;
 }
 
 extern "C" EXPORT void winrt_capture_free(struct winrt_capture *capture)