Skip to content

Commit

Permalink
Bug 799092 - GnuCash 5.4 leaves background process running on exit
Browse files Browse the repository at this point in the history
Clear the schema_hash at app shutdown via gnc_prefs_remove_registered
and make that function available to the Python bindings so that
python programs can do so too.
  • Loading branch information
jralls committed Oct 2, 2023
1 parent fc0e80b commit a389e0a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions bindings/app-utils.i
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ PyObject* SWIG_init (void);
%import "base-typemaps.i"

void gnc_prefs_init();
void gnc_prefs_remove_registered();

QofBook * gnc_get_current_book (void);
QofSession * gnc_get_current_session (void);
Expand Down
10 changes: 7 additions & 3 deletions libgnucash/app-utils/gnc-gsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,7 @@ void gnc_gsettings_load_backend (void)
if (g_strcmp0 (g_getenv ("GNC_UNINSTALLED"), "1") == 0)
return;

if (prefsbackend)
g_free (prefsbackend);

g_free (prefsbackend);
prefsbackend = g_new0 (PrefsBackend, 1);

prefsbackend->register_cb = gnc_gsettings_register_cb;
Expand Down Expand Up @@ -560,6 +558,12 @@ void gnc_gsettings_load_backend (void)
LEAVE("Prefsbackend bind = %p", prefsbackend->bind);
}

void
gnc_gsettings_shutdown (void)
{
schema_hash.clear();
g_free (prefsbackend);
}


static GVariant *
Expand Down
4 changes: 4 additions & 0 deletions libgnucash/app-utils/gnc-gsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,10 @@ void gnc_gsettings_reset_schema (const gchar *schema);
*/
void gnc_gsettings_load_backend (void);

/** Free the GSettings resources.
*/
void gnc_gsettings_shutdown (void);

/** Check whether we need to adjust the user settings
* to a newer version.
*
Expand Down
1 change: 1 addition & 0 deletions libgnucash/app-utils/gnc-prefs-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,5 @@ gnc_prefs_remove_registered (void)
file_retain_type_changed_cb, NULL);
gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL, GNC_PREF_FILE_COMPRESSION,
file_compression_changed_cb, NULL);
gnc_gsettings_shutdown ();
}

0 comments on commit a389e0a

Please sign in to comment.