Fix slow game saves

In some cases when the save directory has a lot of files it was taking
hours to save games due to gtk taking a long time to process new file
events.  This fixes the problem by destroying the file chooser window
before saving a game.

(cherry picked from commit 6d57140a4fd8e59885e139f9cd0e29a18b3ff60d)
This commit is contained in:
Tom Stellard 2022-01-14 17:30:12 -08:00
parent e9b027d5ad
commit 6abdf5872d
1 changed files with 9 additions and 0 deletions

View File

@ -418,6 +418,15 @@ window_show_file_sel(Bygfoot *bygfoot)
if(gtk_dialog_run(GTK_DIALOG(window.file_chooser)) == GTK_RESPONSE_OK)
{
filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(window.file_chooser));
/* When a game is saved, thousands of xml files are written and
* deleted in the current directory. These filesystem changes
* generate new events that get processed when we update the
* progres bar. It takes a very long time to process these events
* and it slows done the save process. We can avoid this issue
* by destoying the file chooser window before we start saving
* the game.
*/
window_destroy(&window.file_chooser);
if(stat5 == STATUS_LOAD_GAME)
load_save_load_game(bygfoot, filename, FALSE);