]> git.sesse.net Git - vlc/blobdiff - src/interface/interaction.c
Interaction: set the p_parent field
[vlc] / src / interface / interaction.c
index efa0939fa7b4292e6e05708e91676a77786f3dc9..c3322c11d4655689a4cb1350699ca639e18617e6 100644 (file)
@@ -75,6 +75,7 @@ static int DialogSend( vlc_object_t *, interaction_dialog_t * );
 #define DIALOG_INIT( type, err ) \
         interaction_dialog_t* p_new = calloc( 1, sizeof( interaction_dialog_t ) ); \
         if( !p_new ) return err;                        \
+        p_new->p_parent = vlc_object_hold( p_this );    \
         p_new->b_cancelled = false;                     \
         p_new->i_status = NEW_DIALOG;                   \
         p_new->i_flags = 0;                             \
@@ -204,20 +205,17 @@ __intf_Progress( vlc_object_t *p_this, const char *psz_title,
 /**
  * Update a progress bar in a dialogue
  *
- * \param p_this           Parent vlc_object
  * \param p_dialog         Dialog
  * \param psz_status       New status
  * \param f_position       New position (0.0->100.0)
  * \param i_timeToGo       Time (in sec) to go until process is finished
  * \return                 nothing
  */
-void __intf_ProgressUpdate( vlc_object_t *p_this,
-                            interaction_dialog_t *p_dialog,
+void intf_ProgressUpdate( interaction_dialog_t *p_dialog,
                             const char *psz_status, float f_pos, int i_time )
 {
-    interaction_t *p_interaction = InteractionGet( p_this );
-
-    if( !p_interaction ) return;
+    interaction_t *p_interaction = InteractionGet( p_dialog->p_parent );
+    assert( p_interaction );
 
     vlc_object_lock( p_interaction );
     free( p_dialog->psz_description );
@@ -237,18 +235,15 @@ void __intf_ProgressUpdate( vlc_object_t *p_this,
  * Helper function to communicate dialogue cancellations between the
  * interface module and the caller
  *
- * \param p_this           Parent vlc_object
  * \param p_dialog         Dialog
  * \return                 Either true or false
  */
-bool __intf_UserProgressIsCancelled( vlc_object_t *p_this,
-                                     interaction_dialog_t *p_dialog )
+bool intf_ProgressIsCancelled( interaction_dialog_t *p_dialog )
 {
-    interaction_t *p_interaction = InteractionGet( p_this );
+    interaction_t *p_interaction = InteractionGet( p_dialog->p_parent );
     bool b_cancel;
 
-    if( !p_interaction ) return true;
-
+    assert( p_interaction );
     vlc_object_lock( p_interaction );
     b_cancel = p_dialog->b_cancelled;
     vlc_object_unlock( p_interaction );
@@ -329,15 +324,13 @@ int __intf_UserStringInput( vlc_object_t *p_this,
 /**
  * Hide an interaction dialog
  *
- * \param p_this the parent vlc object
  * \param p_dialog the dialog to hide
  * \return nothing
  */
-void __intf_UserHide( vlc_object_t *p_this, interaction_dialog_t *p_dialog )
+void intf_UserHide( interaction_dialog_t *p_dialog )
 {
-    interaction_t *p_interaction = InteractionGet( p_this );
-
-    if( !p_interaction ) return;
+    interaction_t *p_interaction = InteractionGet( p_dialog->p_parent );
+    assert( p_interaction );
 
     vlc_object_lock( p_interaction );
     p_dialog->i_status = ANSWERED_DIALOG;
@@ -442,7 +435,7 @@ int interaction_Unregister( intf_thread_t *intf )
  * The following functions are local
  **********************************************************************/
 
-/* Get the interaction object. Create it if needed */
+/* Get the interaction object */
 static interaction_t * InteractionGet( vlc_object_t *p_this )
 {
     interaction_t *obj = libvlc_priv(p_this->p_libvlc)->p_interaction;
@@ -475,6 +468,7 @@ static void DialogDestroy( interaction_dialog_t *p_dialog )
     free( p_dialog->psz_default_button );
     free( p_dialog->psz_alternate_button );
     free( p_dialog->psz_other_button );
+    vlc_object_release( p_dialog->p_parent );
     free( p_dialog );
 }
 
@@ -482,7 +476,7 @@ static void DialogDestroy( interaction_dialog_t *p_dialog )
  * if required */
 static int DialogSend( vlc_object_t *p_this, interaction_dialog_t *p_dialog )
 {
-    interaction_t *p_interaction = InteractionGet( p_this );
+    interaction_t *p_interaction = InteractionGet( p_dialog->p_parent );
 
     if( !p_interaction )
         return VLC_EGENERIC;