| 876 | } |
| 877 | |
| 878 | void GameLoop::loopExit() |
| 879 | { |
| 880 | /* Unvalidate the game pid */ |
| 881 | context->game_pid = 0; |
| 882 | |
| 883 | /* Stop the appimage process */ |
| 884 | if (context->appimage_pid) { |
| 885 | kill(context->appimage_pid, SIGINT); |
| 886 | context->appimage_pid = 0; |
| 887 | } |
| 888 | |
| 889 | /* We need to restart the game if we got a restart input, or if: |
| 890 | * - auto-restart is set |
| 891 | * - we are playing or recording a movie |
| 892 | * - the user didn't use the Stop button to stop the game |
| 893 | */ |
| 894 | |
| 895 | if ((context->status == Context::RESTARTING) || |
| 896 | (context->config.auto_restart && |
| 897 | (context->config.sc.recording != SharedConfig::NO_RECORDING) && |
| 898 | (context->status != Context::QUITTING))) { |
| 899 | |
| 900 | /* We keep the movie opened and indicate the main thread to restart the game */ |
| 901 | |
| 902 | closeSocket(); |
| 903 | |
| 904 | /* Remove savestates because they are invalid on future instances of the game */ |
| 905 | remove_savestates(context); |
| 906 | |
| 907 | /* Backup savestate movies on disk */ |
| 908 | SaveStateList::backupMovies(); |
| 909 | |
| 910 | /* wait on the game process to terminate */ |
| 911 | wait(nullptr); |
| 912 | |
| 913 | context->status = Context::RESTARTING; |
| 914 | emit statusChanged(context->status); |
| 915 | |
| 916 | return; |
| 917 | } |
| 918 | |
| 919 | /* When not recording, silently save a backup movie and inform the user */ |
| 920 | if (context->config.sc.recording == SharedConfig::NO_RECORDING) { |
| 921 | movie.saveBackupMovie(); |
| 922 | } |
| 923 | else if (movie.inputs->modifiedSinceLastSave) { |
| 924 | |
| 925 | /* Ask the user if he wants to save the movie, and get the answer. |
| 926 | * Prompting a alert window must be done by the UI thread, so we are |
| 927 | * using std::future/std::promise mechanism. |
| 928 | */ |
| 929 | std::promise<bool> saveAnswer; |
| 930 | std::future<bool> futureSave = saveAnswer.get_future(); |
| 931 | emit askToShow(QString("Do you want to save the movie file?"), &saveAnswer); |
| 932 | |
| 933 | if (futureSave.get()) { |
| 934 | /* User answered yes */ |
| 935 | movie.saveMovie(); |
nothing calls this directly
no test coverage detected