summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAron Budea <aron.budea@collabora.com>2017-01-23 03:47:19 +0100
committerCaolán McNamara <caolanm@redhat.com>2017-01-23 20:46:59 +0000
commitd3b250cffeba171ca1b1f793d188b1d05f57e66b (patch)
treea0e4e4b5d525d439644599e55b88c85fc7d9c96c
parent9f0b05a64733fcaac39127db5e5f2fa3ad80a1b9 (diff)
tdf#100151: Dispose of window if DX device creation failed
Before, if the device lacked Direct3D capabilities, VclPtr handling became compromised, and caused a crash. This was particularly a problem in virtualized/remote desktop connections in Windows. Now mpWindow instance is disposed of right away if DX device creation fails. Change-Id: I639340380affdb31a93ce6dccd8df33a0a466df6 Reviewed-on: https://gerrit.libreoffice.org/33413 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Jenkins <ci@libreoffice.org> (cherry picked from commit bb50474225f80b8aeea49f14ad66173462026a41) Reviewed-on: https://gerrit.libreoffice.org/33477 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--canvas/source/directx/dx_9rm.cxx19
1 files changed, 11 insertions, 8 deletions
diff --git a/canvas/source/directx/dx_9rm.cxx b/canvas/source/directx/dx_9rm.cxx
index 1f58f2bd8349..4b41d302b54b 100644
--- a/canvas/source/directx/dx_9rm.cxx
+++ b/canvas/source/directx/dx_9rm.cxx
@@ -583,6 +583,14 @@ namespace dxcanvas
// TODO(P2): get rid of those fine-grained locking
::osl::MutexGuard aGuard( maMutex );
+ // TODO(F2): since we would like to share precious hardware
+ // resources, the direct3d9 object should be global. each new
+ // request for a canvas should only create a new swapchain.
+ mpDirect3D9 = COMReference<IDirect3D9>(
+ Direct3DCreate9(D3D_SDK_VERSION));
+ if(!mpDirect3D9.is())
+ return false;
+
maVertexCache.reserve( 1024 );
mpWindow.disposeAndClear();
@@ -619,17 +627,12 @@ namespace dxcanvas
// let the child window cover the same size as the parent window.
mpWindow->setPosSizePixel(0,0,maSize.getX(),maSize.getY());
- // TODO(F2): since we would like to share precious hardware
- // resources, the direct3d9 object should be global. each new
- // request for a canvas should only create a new swapchain.
- mpDirect3D9 = COMReference<IDirect3D9>(
- Direct3DCreate9(D3D_SDK_VERSION));
- if(!mpDirect3D9.is())
- return false;
-
// create a device from the direct3d9 object.
if(!(createDevice()))
+ {
+ mpWindow.disposeAndClear();
return false;
+ }
mpWindow->Show();