diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2017-02-28 02:25:30 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2017-02-28 03:51:12 +0000 |
commit | b5987a4148a10e27fe44ecf5d03e697692e07ca9 (patch) | |
tree | a329a350f01a693756fc52666e0b67fdd2f06c5e | |
parent | 342f5b842ba1ee727732cf103481c3b0b0d3cc79 (diff) |
mpMediaItem might be nullptr
This fixes at least two crashes reported through the crashreporter:
http://crashreport.libreoffice.org/stats/signature/avmedia::MediaItem::getTime()
http://crashreport.libreoffice.org/stats/signature/avmedia::MediaItem::getDuration()
Change-Id: I92eeca229fa46921317586d0317e9f00309e793b
Reviewed-on: https://gerrit.libreoffice.org/34710
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r-- | svx/source/sidebar/media/MediaPlaybackPanel.cxx | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/svx/source/sidebar/media/MediaPlaybackPanel.cxx b/svx/source/sidebar/media/MediaPlaybackPanel.cxx index 71250abbf900..33f4646645d4 100644 --- a/svx/source/sidebar/media/MediaPlaybackPanel.cxx +++ b/svx/source/sidebar/media/MediaPlaybackPanel.cxx @@ -117,10 +117,13 @@ void MediaPlaybackPanel::UpdateToolBoxes(MediaItem aMediaItem) void MediaPlaybackPanel::Update() { - UpdateToolBoxes( *mpMediaItem ); - UpdateTimeSlider( *mpMediaItem ); - UpdateVolumeSlider( *mpMediaItem ); - UpdateTimeField( *mpMediaItem, mpMediaItem->getTime() ); + if (mpMediaItem) + { + UpdateToolBoxes( *mpMediaItem ); + UpdateTimeSlider( *mpMediaItem ); + UpdateVolumeSlider( *mpMediaItem ); + UpdateTimeField( *mpMediaItem, mpMediaItem->getTime() ); + } } IMPL_LINK_NOARG( MediaPlaybackPanel, VolumeSlideHdl, Slider*, void) @@ -134,7 +137,10 @@ IMPL_LINK_NOARG( MediaPlaybackPanel, SeekHdl, Slider*, void) { MediaItem aItem(SID_AVMEDIA_TOOLBOX); aItem.setState( MediaState::Pause ); - aItem.setTime( mpTimeSlider->GetThumbPos() * mpMediaItem->getDuration() / AVMEDIA_TIME_RANGE); + double nTime = 0; + if (mpMediaItem) + nTime = mpTimeSlider->GetThumbPos() * mpMediaItem->getDuration() / AVMEDIA_TIME_RANGE; + aItem.setTime(nTime); mpBindings->GetDispatcher()->ExecuteList(SID_AVMEDIA_TOOLBOX, SfxCallMode::RECORD, { &aItem }); mpBindings->Invalidate(SID_AVMEDIA_TOOLBOX); } @@ -153,7 +159,7 @@ IMPL_LINK( MediaPlaybackPanel, PlayToolBoxSelectHdl, ToolBox*, pControl, void) { aItem.setState( MediaState::Play ); - if( mpMediaItem->getTime() == mpMediaItem->getDuration() ) + if( !mpMediaItem || (mpMediaItem->getTime() == mpMediaItem->getDuration() )) aItem.setTime( 0.0 ); else aItem.setTime( mpMediaItem->getTime()); |