Skip to content

Commit

Permalink
Avoid division by zero
Browse files Browse the repository at this point in the history
...as happens during CppunitTest_sd_dialogs_test when displaying
modules/simpress/ui/headerfootertab.ui:

> sd/source/ui/dlg/headerfooterdlg.cxx:782:63: runtime error: division by zero
>     #0 0x7f270dc78b7f in sd::PresLayoutPreview::Paint(OutputDevice&, Rectangle const&) sd/source/ui/dlg/headerfooterdlg.cxx:782:63
>     #1 0x7f274a56bb53 in PaintHelper::DoPaint(vcl::Region const*) vcl/source/window/paint.cxx:307:24
>     #2 0x7f274a57be32 in vcl::Window::ImplCallPaint(vcl::Region const*, unsigned short) vcl/source/window/paint.cxx:613:17
>     #3 0x7f274a577eee in PaintHelper::~PaintHelper() vcl/source/window/paint.cxx:547:30
>     #4 0x7f274a57c305 in vcl::Window::ImplCallPaint(vcl::Region const*, unsigned short) vcl/source/window/paint.cxx:619:1
>     #5 0x7f274a577eee in PaintHelper::~PaintHelper() vcl/source/window/paint.cxx:547:30
>     #6 0x7f274a57c305 in vcl::Window::ImplCallPaint(vcl::Region const*, unsigned short) vcl/source/window/paint.cxx:619:1
>     #7 0x7f274a589f0d in vcl::Window::Update() vcl/source/window/paint.cxx:1310:24
>     #8 0x7f274b908d23 in ImplHandlePaint(vcl::Window*, Rectangle const&, bool) vcl/source/window/winproc.cxx:1593:18
>     #9 0x7f274b8f9092 in ImplWindowFrameProc(vcl::Window*, SalEvent, void const*) vcl/source/window/winproc.cxx:2437:13
>     #10 0x7f272e3c8662 in SalFrame::CallCallback(SalEvent, void const*) const vcl/inc/salframe.hxx:276:33

Change-Id: I2868a8b0a726544c9edbaab62a8929badf6d3845
  • Loading branch information
stbergmann committed Nov 18, 2016
1 parent 14af38f commit 66da98c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sd/source/ui/dlg/headerfooterdlg.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -774,12 +774,12 @@ void PresLayoutPreview::Paint(vcl::RenderContext& rRenderContext, const Rectangl
if( maPageSize.Width() > maPageSize.Height() )
{
nWidth = maOutRect.GetWidth();
nHeight = long( (double)(nWidth * maPageSize.Height()) / (double)maPageSize.Width() );
nHeight = maPageSize.Width() == 0 ? 0 : long( (double)(nWidth * maPageSize.Height()) / (double)maPageSize.Width() );
}
else
{
nHeight = maOutRect.GetHeight();
nWidth = long( (double)(nHeight * maPageSize.Width()) / (double)maPageSize.Height() );
nWidth = maPageSize.Height() == 0 ? 0 : long( (double)(nHeight * maPageSize.Width()) / (double)maPageSize.Height() );
}

maOutRect.Left() += (maOutRect.GetWidth() - nWidth) >> 1;
Expand Down

0 comments on commit 66da98c

Please sign in to comment.