diff options
author | Caolán McNamara <caolanm@redhat.com> | 2013-10-01 16:23:31 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-10-01 16:23:31 +0100 |
commit | e85eadc888285a42561cc52133172cf5f4317da2 (patch) | |
tree | a76a80808c21429bc40a11669ad5ac78e9838c01 | |
parent | 165aca6a01ede62d0ce7577a90709bd9bd43b769 (diff) |
Resolves: rhbz#1010995 div by 0 on some bizarre corner case
Change-Id: Ief192ac36df7f62c9e157dce9050b37297ccf0a4
-rw-r--r-- | vcl/unx/generic/app/saldisp.cxx | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/vcl/unx/generic/app/saldisp.cxx b/vcl/unx/generic/app/saldisp.cxx index c7cf6e4b88e4..713e9c3a346c 100644 --- a/vcl/unx/generic/app/saldisp.cxx +++ b/vcl/unx/generic/app/saldisp.cxx @@ -596,11 +596,22 @@ void SalDisplay::Init() } if( mbExactResolution == false ) { - aResolution_ = - Pair( DPI( WidthOfScreen( DefaultScreenOfDisplay( pDisp_ ) ), - DisplayWidthMM ( pDisp_, m_nXDefaultScreen.getXScreen() ) ), - DPI( HeightOfScreen( DefaultScreenOfDisplay( pDisp_ ) ), - DisplayHeightMM( pDisp_, m_nXDefaultScreen.getXScreen() ) ) ); + int nDisplayWidth = DisplayWidthMM ( pDisp_, m_nXDefaultScreen.getXScreen() ); + int nDisplayHeight = DisplayHeightMM( pDisp_, m_nXDefaultScreen.getXScreen() ); + + if (nDisplayHeight == 0 || nDisplayWidth == 0) + { + aResolution_ = Pair( 96, 96 ); + SAL_WARN("vcl", "screen width/height reported as 0!, using fallback 96dpi"); + } + else + { + aResolution_ = + Pair( DPI( WidthOfScreen( DefaultScreenOfDisplay( pDisp_ ) ), + nDisplayWidth ), + DPI( HeightOfScreen( DefaultScreenOfDisplay( pDisp_ ) ), + nDisplayHeight ) ); + } } nMaxRequestSize_ = XExtendedMaxRequestSize( pDisp_ ) * 4; |