1.1 --- a/plover-gtk/transactionhelper.c Thu Mar 07 16:57:23 2019 +0000
1.2 +++ b/plover-gtk/transactionhelper.c Fri Mar 08 12:05:41 2019 +0000
1.3 @@ -57,6 +57,10 @@
1.4
1.5 static guint signals[N_SIGNALS];
1.6
1.7 +static PloverTransaction *
1.8 + plover_transaction_helper_new_transaction(PloverTransactionHelper *helper,
1.9 + GError **error);
1.10 +
1.11 static void plover_transaction_helper_finalize(PloverTransactionHelper *helper)
1.12 {
1.13 PloverTransactionHelperPrivate *priv;
1.14 @@ -286,7 +290,23 @@
1.15 "SIRemoveExisting"));
1.16 if (gtk_toggle_button_get_active(button))
1.17 {
1.18 - transaction=plover_transaction_new_remove(NULL,&error);
1.19 + transaction=plover_transaction_helper_new_transaction(helper,&error);
1.20 + /*
1.21 + * I think we want switch to the alternate installed set in the case of
1.22 + * alternate_database_clashes, but not in the case of
1.23 + * active_database_is_incompatible (see
1.24 + * plover_transaction_helper_update_summary_page).
1.25 + * Whether testing for helper->alternate_installed is sufficient I'm
1.26 + * far from clear.
1.27 + */
1.28 + if (helper->alternate_installed)
1.29 + plover_transaction_set_installed(transaction,
1.30 + helper->alternate_installed);
1.31 + if (transaction && !plover_transaction_remove(transaction,NULL,&error))
1.32 + {
1.33 + g_object_unref(transaction);
1.34 + transaction=NULL;
1.35 + }
1.36 if (transaction)
1.37 {
1.38 save_transactions=helper->transactions;
2.1 --- a/plover/transaction.c Thu Mar 07 16:57:23 2019 +0000
2.2 +++ b/plover/transaction.c Fri Mar 08 12:05:41 2019 +0000
2.3 @@ -451,8 +451,7 @@
2.4 retval=plover_package_set_open(installed,install_uri,TRUE,error);
2.5 if (retval)
2.6 plover_transaction_set_installed(transaction,installed);
2.7 - else
2.8 - g_object_unref(installed);
2.9 + g_object_unref(installed);
2.10 free(install_uri);
2.11 return retval;
2.12 }
3.1 --- a/tests/plover/test-transaction.c Thu Mar 07 16:57:23 2019 +0000
3.2 +++ b/tests/plover/test-transaction.c Fri Mar 08 12:05:41 2019 +0000
3.3 @@ -315,13 +315,23 @@
3.4 {
3.5 PloverTransaction *transaction=user_data;
3.6 GError *err=NULL;
3.7 + GSource *delayed_quit;
3.8 if (!plover_transaction_commit_finish(transaction,result,&err))
3.9 {
3.10 g_assert(err && err->message);
3.11 g_error("test-commit: %s",err->message);
3.12 }
3.13 g_assert(!err);
3.14 - g_main_loop_quit(test_commit_mainloop);
3.15 + /*
3.16 + * We use a delayed quit rather than calling g_main_loop_quit() directly
3.17 + * so that GTask has a chance to clean up (including dropping its
3.18 + * reference on transaction).
3.19 + */
3.20 + delayed_quit=g_timeout_source_new_seconds(1);
3.21 + g_source_set_callback(delayed_quit,g_main_loop_quit,test_commit_mainloop,
3.22 + NULL);
3.23 + g_source_attach(delayed_quit,g_main_loop_get_context(test_commit_mainloop));
3.24 + g_source_unref(delayed_quit);
3.25 }
3.26
3.27 static void test_commit(void)