Thu, 11 Nov 2021 20:20:49 -0600
Clean up some issues during shutdown that were outputting warnings
Testing Done:
Ran and verified that the warnings were no longer displayed.
Reviewed at https://reviews.imfreedom.org/r/1128/
| libpurple/core.c | file | annotate | diff | comparison | revisions | |
| libpurple/purplecredentialmanager.c | file | annotate | diff | comparison | revisions |
--- a/libpurple/core.c Thu Nov 11 20:12:05 2021 -0600 +++ b/libpurple/core.c Thu Nov 11 20:20:49 2021 -0600 @@ -37,6 +37,7 @@ #include "proxy.h" #include "purpleconversation.h" #include "purplecredentialmanager.h" +#include "purplehistorymanager.h" #include "purplemessage.h" #include "purpleprivate.h" #include "savedstatuses.h" @@ -202,20 +203,25 @@ { PurpleCoreUiOps *ops; PurpleCore *core = purple_get_core(); - PurpleCredentialManager *manager = NULL; + PurpleCredentialManager *credential_manager = NULL; + PurpleHistoryManager *history_manager = NULL; g_return_if_fail(core != NULL); /* The self destruct sequence has been initiated */ purple_signal_emit(purple_get_core(), "quitting"); - /* Remove the active provider in the credential manager. */ - manager = purple_credential_manager_get_default(); - purple_credential_manager_set_active(manager, NULL, NULL); - /* Transmission ends */ purple_connections_disconnect_all(); + /* Remove the active provider in the credential manager. */ + credential_manager = purple_credential_manager_get_default(); + purple_credential_manager_set_active(credential_manager, NULL, NULL); + + /* Remove the active history adapter */ + history_manager = purple_history_manager_get_default(); + purple_history_manager_set_active(history_manager, NULL, NULL); + /* Save .xml files, remove signals, etc. */ purple_idle_uninit(); purple_whiteboard_manager_shutdown();
--- a/libpurple/purplecredentialmanager.c Thu Nov 11 20:12:05 2021 -0600 +++ b/libpurple/purplecredentialmanager.c Thu Nov 11 20:20:49 2021 -0600 @@ -166,15 +166,9 @@ static void purple_credential_manager_init(PurpleCredentialManager *manager) { - PurpleCredentialProvider *noop = NULL; - manager->providers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref); - noop = purple_noop_credential_provider_new(); - purple_credential_manager_register(manager, noop, NULL); - g_object_unref(G_OBJECT(noop)); - /* Connect to the core-initialized signal so we can alert the user if we * were unable to find their credential provider. */ @@ -263,10 +257,27 @@ /****************************************************************************** * Private API *****************************************************************************/ + +/* Currently we're auto-registering the noop provider on the default manager, + * this may get moved to purple core later, so we just want to keep it all in + * one place for now. + */ +static PurpleCredentialProvider *noop = NULL; + void purple_credential_manager_startup(void) { if(default_manager == NULL) { + GError *error = NULL; + default_manager = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL); + + noop = purple_noop_credential_provider_new(); + if(!purple_credential_manager_register(default_manager, noop, &error)) { + g_warning("failed to register the noop credential manager: %s", + error ? error->message : "unknown"); + g_clear_error(&error); + g_clear_object(&noop); + } } } @@ -275,6 +286,21 @@ if(PURPLE_IS_CREDENTIAL_MANAGER(default_manager)) { guint size = 0; + /* If we have an instance of the noop provider we need to unregister + * it before continuing. + */ + if(PURPLE_IS_CREDENTIAL_PROVIDER(noop)) { + GError *error = NULL; + if(!purple_credential_manager_unregister(default_manager, + noop, &error)) + { + g_warning("failed to unregister the noop provider: %s", + error ? error->message : "unknown"); + g_clear_error(&error); + } + g_clear_object(&noop); + } + size = g_hash_table_size(default_manager->providers); if(size > 0) { g_warning("purple_credential_manager_shutdown called while %d "