gplugin/gplugin

Fix a leak in settings list

14 months ago, Elliott Sales de Andrade
2695cbb5e004
Fix a leak in settings list

Fixes a leak for plugins that have settings:
```
48 (32 direct, 16 indirect) bytes in 1 blocks are definitely lost in loss record 12,560 of 29,780
at 0x4A231EF: g_type_create_instance (gtype.c:1909)
by 0x4A08C1F: g_object_new_internal (gobject.c:2228)
by 0x4A0A247: g_object_new_with_properties (gobject.c:2391)
by 0x4A0AFF0: g_object_new (gobject.c:2037)
by 0x4C64DA7: gtk_size_group_new (gtksizegroup.c:300)
by 0x487356A: gplugin_gtk_plugin_settings_list_refresh (gplugin-gtk-plugin-settings-list.c:492)
by 0x4873CBA: gplugin_gtk_plugin_settings_list_set_settings (gplugin-gtk-plugin-settings-list.c:662)
by 0x4870DEE: gplugin_gtk_plugin_page_update_settings_list (gplugin-gtk-plugin-page.c:98)
by 0x48717DD: gplugin_gtk_plugin_page_set_plugin (gplugin-gtk-plugin-page.c:394)
by 0x48750EF: gplugin_gtk_view_show_plugin (gplugin-gtk-view.c:567)
by 0x4873FD0: gplugin_gtk_view_row_activated (gplugin-gtk-view.c:82)
by 0x49F8A64: g_cclosure_marshal_VOID__OBJECTv (gmarshal.c:1910)
```

Testing Done:
Opened viewer in valgrind, went to settings plugin's info, and leak was no longer there.

Reviewed at https://reviews.imfreedom.org/r/2305/
LUA = dependency('', required: false)
if get_option('lua')
if not get_option('introspection')
error('Lua plugin requires GObject Introspection.')
endif
GPLUGIN_LUA_SOURCES = [
'gplugin-lua-core.c',
'gplugin-lua-loader.c',
'gplugin-lua-plugin.c',
]
GPLUGIN_LUA_HEADERS = [
'gplugin-lua-loader.h',
'gplugin-lua-plugin.h',
]
# These are ordered from most to least preferred, which would normally
# be from the highest to lowest version.
_LUAS = [
['lua-5.4', '>=5.4.0'],
['lua-5.3', '>=5.3.0'],
['lua5.3', '>=5.3.0'],
['lua-5.2', '>=5.2.0'],
['lua5.2', '>=5.2.0'],
['lua52', '>=5.2.0'],
['luajit', '>=2.0.0'],
['lua-5.1', '>=5.1.0'],
['lua5.1', '>=5.1.0'],
['lua', '>=5.1.0'],
]
LUA_FOUND = false
foreach _LUA : _LUAS
LUA = dependency(_LUA[0], version : _LUA[1], required : false)
if LUA.found()
# Compile and run our lua-lgi test program
lua_lgi_test = compiler.run(files('gplugin-lua-test-lgi.c'),
dependencies : LUA,
name : 'lua "lgi" module')
if lua_lgi_test.compiled() and lua_lgi_test.returncode() == 0
LUA_FOUND = true
break
endif
endif
endforeach
if not LUA_FOUND
error('No usable Lua library was found')
endif
endif # lua
summary('Lua', LUA, section : 'Loader Support', bool_yn : true)
if not LUA.found()
subdir_done()
endif
# now add the library
shared_library('gplugin-lua',
GPLUGIN_LUA_SOURCES,
GPLUGIN_LUA_HEADERS,
name_prefix : '',
c_args : ['-DG_LOG_USE_STRUCTURED', '-DG_LOG_DOMAIN="GPlugin-Lua"'],
dependencies : [LUA, gplugin_dep],
install : true,
install_dir : get_option('libdir') / 'gplugin'
)
# Add the loader's path to our environment variable
devenv.append('GPLUGIN_PLUGIN_PATH', meson.current_build_dir())
subdir('tests')