mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	gsettings: free the module-group GSettings objects after use
g_settings_get_child() returns a new GSettings object that needs to be freed when it's not used any more. This patch collects all the childern to a GPtrArray and frees them at the end of main(). They can't be freed earlier, because that would prevent the "changed" signals from being delivered.
This commit is contained in:
		
							parent
							
								
									705779eddd
								
							
						
					
					
						commit
						2977afb9b0
					
				
					 1 changed files with 4 additions and 0 deletions
				
			
		| 
						 | 
					@ -79,6 +79,7 @@ static void module_group_callback(GSettings *settings, gchar *key, gpointer user
 | 
				
			||||||
int main(int argc, char *argv[]) {
 | 
					int main(int argc, char *argv[]) {
 | 
				
			||||||
    GMainLoop *g;
 | 
					    GMainLoop *g;
 | 
				
			||||||
    GSettings *settings;
 | 
					    GSettings *settings;
 | 
				
			||||||
 | 
					    GPtrArray *groups;
 | 
				
			||||||
    gchar **group_names, **name;
 | 
					    gchar **group_names, **name;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if !GLIB_CHECK_VERSION(2,36,0)
 | 
					#if !GLIB_CHECK_VERSION(2,36,0)
 | 
				
			||||||
| 
						 | 
					@ -88,6 +89,7 @@ int main(int argc, char *argv[]) {
 | 
				
			||||||
    if (!(settings = g_settings_new(PA_GSETTINGS_MODULE_GROUPS_SCHEMA)))
 | 
					    if (!(settings = g_settings_new(PA_GSETTINGS_MODULE_GROUPS_SCHEMA)))
 | 
				
			||||||
        goto fail;
 | 
					        goto fail;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    groups = g_ptr_array_new_full(0, g_object_unref);
 | 
				
			||||||
    group_names = g_settings_list_children(settings);
 | 
					    group_names = g_settings_list_children(settings);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (name = group_names; *name; name++) {
 | 
					    for (name = group_names; *name; name++) {
 | 
				
			||||||
| 
						 | 
					@ -98,6 +100,7 @@ int main(int argc, char *argv[]) {
 | 
				
			||||||
        if (!child)
 | 
					        if (!child)
 | 
				
			||||||
            continue;
 | 
					            continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        g_ptr_array_add(groups, child);
 | 
				
			||||||
        g_signal_connect(child, "changed", (GCallback) module_group_callback, *name);
 | 
					        g_signal_connect(child, "changed", (GCallback) module_group_callback, *name);
 | 
				
			||||||
        handle_module_group(*name);
 | 
					        handle_module_group(*name);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -110,6 +113,7 @@ int main(int argc, char *argv[]) {
 | 
				
			||||||
    g_main_loop_run(g);
 | 
					    g_main_loop_run(g);
 | 
				
			||||||
    g_main_loop_unref(g);
 | 
					    g_main_loop_unref(g);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    g_ptr_array_unref(groups);
 | 
				
			||||||
    g_object_unref(G_OBJECT(settings));
 | 
					    g_object_unref(G_OBJECT(settings));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue