[Libreoffice-commits] core.git: svx/source

Markus Mohrhard markus.mohrhard at googlemail.com
Tue Feb 28 03:51:40 UTC 2017


 svx/source/sidebar/media/MediaPlaybackPanel.cxx |   18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

New commits:
commit b5987a4148a10e27fe44ecf5d03e697692e07ca9
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Feb 28 02:25:30 2017 +0100

    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 at libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/svx/source/sidebar/media/MediaPlaybackPanel.cxx b/svx/source/sidebar/media/MediaPlaybackPanel.cxx
index 71250ab..33f4646 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());


More information about the Libreoffice-commits mailing list