From e550527bb4623b7808beabddd16719521bd1905d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= Date: Mon, 18 Sep 2017 21:00:06 +0300 Subject: [PATCH] Fixed|Client|libcommon: Handling a corrupt save file without terminating The case of a save file with bad metadata should be gracefully handled with normal error messages. http://talk.dengine.net/discussion/2489/new-error-on-launch-app-init-failed-gameidentitykey-not-found --- doomsday/apps/client/src/ui/savelistdata.cpp | 15 ++++++++++++--- .../apps/plugins/common/src/game/saveslots.cpp | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/doomsday/apps/client/src/ui/savelistdata.cpp b/doomsday/apps/client/src/ui/savelistdata.cpp index 35073f9a9e..9c70f7a07f 100644 --- a/doomsday/apps/client/src/ui/savelistdata.cpp +++ b/doomsday/apps/client/src/ui/savelistdata.cpp @@ -75,10 +75,19 @@ DENG2_PIMPL(SaveListData) { foreach (File *file, SaveGames::get().saveIndex().files()) { - GameStateFolder &save = file->as(); - if (shouldAddFolder(save)) + try { - self().append(new SaveItem(save)); + GameStateFolder &save = file->as(); + if (shouldAddFolder(save)) + { + self().append(new SaveItem(save)); + } + } + catch (Error const &er) + { + LOG_ERROR("Save file %s has corrupt metadata: %s") + << file->description() + << er.asText(); } } } diff --git a/doomsday/apps/plugins/common/src/game/saveslots.cpp b/doomsday/apps/plugins/common/src/game/saveslots.cpp index 945bde6fca..56a541fedd 100644 --- a/doomsday/apps/plugins/common/src/game/saveslots.cpp +++ b/doomsday/apps/plugins/common/src/game/saveslots.cpp @@ -67,7 +67,7 @@ DENG2_PIMPL_NOREF(SaveSlots::Slot) { status = Incompatible; // Game identity key missmatch? - if (!session->metadata().gets("gameIdentityKey").compareWithoutCase(COMMON_GAMESESSION->gameId())) + if (!session->metadata().gets("gameIdentityKey", "").compareWithoutCase(COMMON_GAMESESSION->gameId())) { /// @todo Validate loaded add-ons and checksum the definition database. status = Loadable; // It's good!