Bug 1026893 - "crash in @0x0 | CContext::ID3D11DeviceContext1_SetSamplers_<int, 5>(ID3D11DeviceContext1*, unsigned int, unsigned int, ID3D11SamplerState* const*)". r=jmuizelaar a=sledru
Bug 1026893 - "crash in @0x0 | CContext::ID3D11DeviceContext1_SetSamplers_<int, 5>(ID3D11DeviceContext1*, unsigned int, unsigned int, ID3D11SamplerState* const*)". r=jmuizelaar a=sledru
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -382,17 +382,17 @@ gfxWindowsPlatform::UpdateRenderMode()
// Do not ever try if d2d is explicitly disabled,
// or if we're not using DWrite fonts.
if (d2dDisabled || mUsingGDIFonts) {
tryD2D = false;
}
if (isVistaOrHigher && !safeMode && tryD2D) {
VerifyD2DDevice(d2dForceEnabled);
- if (mD2DDevice) {
+ if (mD2DDevice && GetD3D11Device()) {
mRenderMode = RENDER_DIRECT2D;
mUseDirectWrite = true;
}
} else {
mD2DDevice = nullptr;
}
#endif
@@ -1380,20 +1380,26 @@ gfxWindowsPlatform::GetD3D11Device()
featureLevels.AppendElement(D3D_FEATURE_LEVEL_9_3);
RefPtr<IDXGIAdapter1> adapter = GetDXGIAdapter();
if (!adapter) {
return nullptr;
}
- HRESULT hr = d3d11CreateDevice(adapter, D3D_DRIVER_TYPE_UNKNOWN, nullptr,
- D3D11_CREATE_DEVICE_BGRA_SUPPORT,
- featureLevels.Elements(), featureLevels.Length(),
- D3D11_SDK_VERSION, byRef(mD3D11Device), nullptr, nullptr);
+ HRESULT hr = E_INVALIDARG;
+ __try {
+ hr = d3d11CreateDevice(adapter, D3D_DRIVER_TYPE_UNKNOWN, nullptr,
+ D3D11_CREATE_DEVICE_BGRA_SUPPORT,
+ featureLevels.Elements(), featureLevels.Length(),
+ D3D11_SDK_VERSION, byRef(mD3D11Device), nullptr, nullptr);
+ } __except (EXCEPTION_EXECUTE_HANDLER) {
+ mD3D11Device = nullptr;
+ return nullptr;
+ }
// We leak these everywhere and we need them our entire runtime anyway, let's
// leak it here as well.
d3d11Module.disown();
if (SUCCEEDED(hr)) {
mD3D11Device->SetExceptionMode(0);
}