]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/extended_panels.cpp
Fix a crash that happens if you play with video filters.
[vlc] / modules / gui / qt4 / components / extended_panels.cpp
index 018a697f0bdd94018434d10c4cb127c06a1471c8..04d07f1a49c59a96d3c03257de7001144ca1a535 100644 (file)
@@ -94,6 +94,7 @@ ExtVideo::ExtVideo( intf_thread_t *_p_intf, QTabWidget *_parent ) :
                            p_intf( _p_intf )
 {
     ui.setupUi( _parent );
+    p_vout = NULL;
 
 #define SETUP_VFILTER( widget ) \
     { \
@@ -221,17 +222,29 @@ ExtVideo::~ExtVideo()
 
 void ExtVideo::cropChange()
 {
-    p_vout = ( vout_thread_t * )vlc_object_find( p_intf,
-                                VLC_OBJECT_VOUT, FIND_CHILD );
-    if( p_vout )
+    if( THEMIM->getInput() )
     {
-        var_SetInteger( p_vout, "crop-top", ui.cropTopPx->value() );
-        var_SetInteger( p_vout, "crop-bottom", ui.cropBotPx->value() );
-        var_SetInteger( p_vout, "crop-left", ui.cropLeftPx->value() );
-        var_SetInteger( p_vout, "crop-right", ui.cropRightPx->value() );
+        p_vout = ( vout_thread_t * )vlc_object_find( THEMIM->getInput(),
+                VLC_OBJECT_VOUT, FIND_CHILD );
+        if( p_vout )
+        {
+            var_SetInteger( p_vout, "crop-top", ui.cropTopPx->value() );
+            var_SetInteger( p_vout, "crop-bottom", ui.cropBotPx->value() );
+            var_SetInteger( p_vout, "crop-left", ui.cropLeftPx->value() );
+            var_SetInteger( p_vout, "crop-right", ui.cropRightPx->value() );
+        }
+        vlc_object_release( p_vout );
     }
 }
 
+void ExtVideo::clean()
+{
+    ui.cropTopPx->setValue( 0 );
+    ui.cropBotPx->setValue( 0 );
+    ui.cropLeftPx->setValue( 0 );
+    ui.cropRightPx->setValue( 0 );
+}
+
 void ExtVideo::ChangeVFiltersString( char *psz_name, bool b_add )
 {
     char *psz_parser, *psz_string;
@@ -327,8 +340,13 @@ void ExtVideo::ChangeVFiltersString( char *psz_name, bool b_add )
         ui.subpictureFilterText->setText( psz_string );
 
     /* Try to set on the fly */
-    p_vout = ( vout_thread_t * )vlc_object_find( p_intf, VLC_OBJECT_VOUT,
-                                              FIND_ANYWHERE );
+    if( THEMIM->getInput() )
+        p_vout = ( vout_thread_t * )vlc_object_find( THEMIM->getInput(),
+                VLC_OBJECT_VOUT, FIND_CHILD );
+    /* If you have stopped the video, p_vout is still at its old value */
+    else
+        p_vout = NULL;
+
     if( p_vout )
     {
         if( !strcmp( psz_filter_type, "sub-filter" ) )
@@ -344,7 +362,6 @@ void ExtVideo::ChangeVFiltersString( char *psz_name, bool b_add )
 void ExtVideo::updateFilters()
 {
     QString module = ModuleFromWidgetName( sender() );
-    //std::cout << "Module name: " << module.toStdString() << std::endl;
 
     QCheckBox *checkbox = qobject_cast<QCheckBox*>( sender() );
     QGroupBox *groupbox = qobject_cast<QGroupBox*>( sender() );
@@ -853,10 +870,15 @@ Equalizer::~Equalizer()
 {
 }
 
+void Equalizer::clean()
+{
+    ui.enableCheck->setChecked( false );
+    enable();
+}
 /* Write down initial values */
 void Equalizer::updateUIFromCore()
 {
-    char *psz_af;//, *psz_bands; Don't use it ?
+    char *psz_af;
     float f_preamp;
     int i_preset;
 
@@ -867,7 +889,6 @@ void Equalizer::updateUIFromCore()
         psz_af = var_GetNonEmptyString( p_aout, "audio-filter" );
         if( var_GetBool( p_aout, "equalizer-2pass" ) )
             ui.eq2PassCheck->setChecked( true );
-//        psz_bands = var_GetNonEmptyString( p_aout, "equalizer-bands" );
         f_preamp = var_GetFloat( p_aout, "equalizer-preamp" );
         i_preset = presetsComboBox->findData( QVariant(
                     var_GetString( p_aout, "equalizer-preset" ) ) );
@@ -878,7 +899,6 @@ void Equalizer::updateUIFromCore()
         psz_af = config_GetPsz( p_intf, "audio-filter" );
         if( config_GetInt( p_intf, "equalizer-2pass" ) )
             ui.eq2PassCheck->setChecked( true );
-//        psz_bands = config_GetPsz( p_intf, "equalizer-bands" );
         f_preamp = config_GetFloat( p_intf, "equalizer-preamp" );
         i_preset = presetsComboBox->findData( QVariant(
                     config_GetPsz( p_intf, "equalizer-preset" ) ) );
@@ -1004,7 +1024,7 @@ void Equalizer::updateUISliderValues( int i_preset )
 
             bands[i]->setValue( (int)( ( f + 20 ) * 10 )  );
 
-            band_texts[i]->setText( band_frequencies[i] + "\n" 
+            band_texts[i]->setText( band_frequencies[i] + "\n"
                                   + QString("%1").arg( f, 5, 'f', 1 ) + "dB" );
             if( p == NULL || *p == '\0' )
                 break;
@@ -1267,8 +1287,8 @@ SyncControls::SyncControls( intf_thread_t *_p_intf, QWidget *_parent ) :
     AVSpin = new QDoubleSpinBox;
     AVSpin->setAlignment( Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter );
     AVSpin->setDecimals( 3 );
-    AVSpin->setMinimum( -100 );
-    AVSpin->setMaximum( 100 );
+    AVSpin->setMinimum( -100.0 );
+    AVSpin->setMaximum( 100.0 );
     AVSpin->setSingleStep( 0.1 );
     AVSpin->setToolTip( qtr( "A positive value means that\n"
                              "the audio is ahead of the video" ) );
@@ -1300,8 +1320,8 @@ SyncControls::SyncControls( intf_thread_t *_p_intf, QWidget *_parent ) :
     subsSpin = new QDoubleSpinBox;
     subsSpin->setAlignment( Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter );
     subsSpin->setDecimals( 3 );
-    subsSpin->setMinimum( -100 );
-    subsSpin->setMaximum( 100 );
+    subsSpin->setMinimum( -100.0 );
+    subsSpin->setMaximum( 100.0 );
     subsSpin->setSingleStep( 0.1 );
     subsSpin->setToolTip( qtr( "A positive value means that\n"
                              "the subtitles are ahead of the video" ) );
@@ -1358,6 +1378,13 @@ SyncControls::SyncControls( intf_thread_t *_p_intf, QWidget *_parent ) :
     update();
 }
 
+void SyncControls::clean()
+{
+    AVSpin->setValue( 0.0 );
+    subsSpin->setValue( 0.0 );
+    subSpeedSpin->setValue( 1.0 );
+}
+
 void SyncControls::update()
 {
     int64_t i_delay;
@@ -1376,9 +1403,8 @@ void SyncControls::advanceAudio( double f_advance )
     if( THEMIM->getInput() )
     {
         int64_t i_delay = var_GetTime( THEMIM->getInput(), "audio-delay" );
-        i_delay += f_advance * 1000000;
+        i_delay = f_advance * 1000000;
         var_SetTime( THEMIM->getInput(), "audio-delay", i_delay );
-        msg_Dbg( p_intf, "I am advancing Audio %d", f_advance );
     }
 }
 
@@ -1387,7 +1413,7 @@ void SyncControls::advanceSubs( double f_advance )
     if( THEMIM->getInput() )
     {
         int64_t i_delay = var_GetTime( THEMIM->getInput(), "spu-delay" );
-        i_delay += f_advance * 1000000;
+        i_delay = f_advance * 1000000;
         var_SetTime( THEMIM->getInput(), "spu-delay", i_delay );
         msg_Dbg( p_intf, "I am advancing subtitles %d", f_advance );
     }