[vlc-commits] [Git][videolan/vlc][master] 2 commits: DBus control module: destroy events at exit

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Feb 2 05:58:49 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
1832179c by Jorge Bellon-Castro at 2023-02-02T05:44:24+00:00
DBus control module: destroy events at exit

- - - - -
fe7f7949 by Jorge Bellon-Castro at 2023-02-02T05:44:24+00:00
Dbus control module: release linked-list elements

Fixes a memory leak where elements in the linked list of events where
never released, due to the release function being always called at the
end of the traversal instead of every iteration.

- - - - -


2 changed files:

- modules/control/dbus/dbus.c
- modules/control/dbus/dbus_tracklist.c


Changes:

=====================================
modules/control/dbus/dbus.c
=====================================
@@ -404,6 +404,14 @@ static void Close   ( vlc_object_t *p_this )
     for( size_t i = 0; i < vlc_array_count( &p_sys->events ); i++ )
     {
         callback_info_t* info = vlc_array_item_at_index( &p_sys->events, i );
+        switch( info->signal ) {
+        case SIGNAL_PLAYLIST_ITEM_APPEND:
+            tracklist_append_event_destroy( info->items_appended );
+            break;
+        case SIGNAL_PLAYLIST_ITEM_DELETED:
+            tracklist_remove_event_destroy( info->items_removed );
+            break;
+        }
         free( info );
     }
     vlc_array_clear( &p_sys->events );
@@ -665,8 +673,10 @@ static void ProcessEvents( intf_thread_t *p_intf,
             vlc_dictionary_insert( &player_properties, "Metadata", NULL );
             break;
         case SIGNAL_PLAYLIST_ITEM_APPEND:
+            if ( !last_append ) {
+                last_append = vlc_dictionary_value_for_key( &tracklist_properties, "TrackAdded" );
+            }
             if( !last_append ) {
-                assert (!vlc_dictionary_has_key( &tracklist_properties, "TrackAdded" ) );
                 vlc_dictionary_insert( &tracklist_properties, "TrackAdded", p_events[i]->items_appended );
 
                 last_append = p_events[i]->items_appended;


=====================================
modules/control/dbus/dbus_tracklist.c
=====================================
@@ -613,29 +613,31 @@ int TrackListPropertiesChangedEmit( intf_thread_t    * p_intf,
         tracklist_append_event_t *added_tracks =
             vlc_dictionary_value_for_key( p_changed_properties, "TrackAdded" );
 
-        while (added_tracks) {
+        while ( added_tracks ) {
             for (size_t i = 0; i < added_tracks->change_ev.count; ++i) {
                 TrackAddedSignal( p_intf,
                         added_tracks->change_ev.index + i,
                         added_tracks->items[i] );
             }
-            added_tracks = tracklist_append_event_next(added_tracks);
+            tracklist_append_event_t *next = tracklist_append_event_next( added_tracks );
+            tracklist_append_event_destroy( added_tracks );
+            added_tracks = next;
         }
-        tracklist_append_event_destroy( added_tracks );
     }
 
     if( vlc_dictionary_has_key( p_changed_properties, "TrackRemoved" ) ) {
         tracklist_remove_event_t *removed_tracks =
             vlc_dictionary_value_for_key( p_changed_properties, "TrackRemoved" );
 
-        while (removed_tracks) {
+        while ( removed_tracks ) {
             for (size_t i = 0; i < removed_tracks->change_ev.count; ++i) {
                 TrackRemovedSignal( p_intf, removed_tracks->change_ev.index + i );
             }
-            removed_tracks = tracklist_remove_event_next(removed_tracks);
+            tracklist_remove_event_t *next = tracklist_remove_event_next( removed_tracks );
+            tracklist_remove_event_destroy( removed_tracks );
+            removed_tracks = next;
         }
 
-        tracklist_remove_event_destroy( removed_tracks );
     }
 
     return VLC_SUCCESS;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/dfde8b0e0920e2c2140b8c051537f949610c9c51...fe7f7949c48ef9dd8cf66d993db060837c9c6dd7

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/dfde8b0e0920e2c2140b8c051537f949610c9c51...fe7f7949c48ef9dd8cf66d993db060837c9c6dd7
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list