# HG changeset patch # User J. Ali Harlow # Date 1552046741 0 # Node ID a8e48c62ec0314d43e415df78a20dcaf39db95c6 # Parent d8a8f04c91aaad0bc518c17a6272befa8582eed3 Fix historic issues exposed by the testsuite diff -r d8a8f04c91aa -r a8e48c62ec03 plover-gtk/transactionhelper.c --- a/plover-gtk/transactionhelper.c Thu Mar 07 16:57:23 2019 +0000 +++ b/plover-gtk/transactionhelper.c Fri Mar 08 12:05:41 2019 +0000 @@ -57,6 +57,10 @@ static guint signals[N_SIGNALS]; +static PloverTransaction * + plover_transaction_helper_new_transaction(PloverTransactionHelper *helper, + GError **error); + static void plover_transaction_helper_finalize(PloverTransactionHelper *helper) { PloverTransactionHelperPrivate *priv; @@ -286,7 +290,23 @@ "SIRemoveExisting")); if (gtk_toggle_button_get_active(button)) { - transaction=plover_transaction_new_remove(NULL,&error); + transaction=plover_transaction_helper_new_transaction(helper,&error); + /* + * I think we want switch to the alternate installed set in the case of + * alternate_database_clashes, but not in the case of + * active_database_is_incompatible (see + * plover_transaction_helper_update_summary_page). + * Whether testing for helper->alternate_installed is sufficient I'm + * far from clear. + */ + if (helper->alternate_installed) + plover_transaction_set_installed(transaction, + helper->alternate_installed); + if (transaction && !plover_transaction_remove(transaction,NULL,&error)) + { + g_object_unref(transaction); + transaction=NULL; + } if (transaction) { save_transactions=helper->transactions; diff -r d8a8f04c91aa -r a8e48c62ec03 plover/transaction.c --- a/plover/transaction.c Thu Mar 07 16:57:23 2019 +0000 +++ b/plover/transaction.c Fri Mar 08 12:05:41 2019 +0000 @@ -451,8 +451,7 @@ retval=plover_package_set_open(installed,install_uri,TRUE,error); if (retval) plover_transaction_set_installed(transaction,installed); - else - g_object_unref(installed); + g_object_unref(installed); free(install_uri); return retval; } diff -r d8a8f04c91aa -r a8e48c62ec03 tests/plover/test-transaction.c --- a/tests/plover/test-transaction.c Thu Mar 07 16:57:23 2019 +0000 +++ b/tests/plover/test-transaction.c Fri Mar 08 12:05:41 2019 +0000 @@ -315,13 +315,23 @@ { PloverTransaction *transaction=user_data; GError *err=NULL; + GSource *delayed_quit; if (!plover_transaction_commit_finish(transaction,result,&err)) { g_assert(err && err->message); g_error("test-commit: %s",err->message); } g_assert(!err); - g_main_loop_quit(test_commit_mainloop); + /* + * We use a delayed quit rather than calling g_main_loop_quit() directly + * so that GTask has a chance to clean up (including dropping its + * reference on transaction). + */ + delayed_quit=g_timeout_source_new_seconds(1); + g_source_set_callback(delayed_quit,g_main_loop_quit,test_commit_mainloop, + NULL); + g_source_attach(delayed_quit,g_main_loop_get_context(test_commit_mainloop)); + g_source_unref(delayed_quit); } static void test_commit(void)