Бранимир Караџић 2 年 前
コミット
448a42a8c6
1 ファイル変更13 行追加8 行削除
  1. 13 8
      src/dxgi.cpp

+ 13 - 8
src/dxgi.cpp

@@ -27,8 +27,8 @@ namespace WinUI3
 	ISwapChainPanelNative : public IUnknown
 	{
 	public:
-		virtual HRESULT STDMETHODCALLTYPE SetSwapChain( 
-			/* [annotation][in] */ 
+		virtual HRESULT STDMETHODCALLTYPE SetSwapChain(
+			/* [annotation][in] */
 			_In_  IDXGISwapChain *swapChain) = 0;
 	};
 
@@ -37,8 +37,8 @@ namespace WinUI3
 	ISwapChainBackgroundPanelNative : public IUnknown
 	{
 	public:
-		virtual HRESULT STDMETHODCALLTYPE SetSwapChain( 
-			/* [annotation][in] */ 
+		virtual HRESULT STDMETHODCALLTYPE SetSwapChain(
+			/* [annotation][in] */
 			_In_  IDXGISwapChain *swapChain) = 0;
 	};
 }
@@ -144,14 +144,14 @@ namespace bgfx
 	{
 		ISwapChainPanelNative* swapChainPanelNative = NULL;
 
-		if (NULL != nativeWindow && FAILED(nativeWindow->QueryInterface(__uuidof(T), (void**)&swapChainPanelNative))
+		if (FAILED(nativeWindow->QueryInterface(__uuidof(T), (void**)&swapChainPanelNative) )
 		||  NULL == swapChainPanelNative)
 		{
 			return false;
 		}
 
 		*hr = swapChainPanelNative->SetSwapChain(swapChain);
-		if (SUCCEEDED(*hr))
+		if (SUCCEEDED(*hr) )
 		{
 			DX_RELEASE_I(swapChainPanelNative);
 		}
@@ -167,6 +167,11 @@ namespace bgfx
 	{
 		HRESULT hr = S_OK;
 
+		if (NULL == nativeWindow)
+		{
+			return hr;
+		}
+
 		if (trySetSwapChain<ISwapChainPanelNative>(nativeWindow, swapChain, &hr)
 		||  trySetSwapChain<ISwapChainBackgroundPanelNative>(nativeWindow, swapChain, &hr)
 		||  trySetSwapChain<WinUI3::ISwapChainPanelNative>(nativeWindow, swapChain, &hr)
@@ -558,7 +563,7 @@ namespace bgfx
 #	if BX_PLATFORM_WINRT
 			IInspectable* nativeWindow = reinterpret_cast<IInspectable*>(_scd.nwh);
 			hr = setSwapChain(nativeWindow, *_swapChain);
-			if (FAILED(hr))
+			if (FAILED(hr) )
 			{
 				return hr;
 			}
@@ -634,7 +639,7 @@ namespace bgfx
 		IInspectable* nativeWindow = reinterpret_cast<IInspectable*>(_scd.nwh);
 		return setSwapChain(nativeWindow, NULL);
 	}
-#endif
+#endif // BX_PLATFORM_WINRT
 
 	void Dxgi::updateHdr10(SwapChainI* _swapChain, const SwapChainDesc& _scd)
 	{