Skip to content

Commit

Permalink
Track the exception thrown by W_LoadPalette
Browse files Browse the repository at this point in the history
It turns out that CMD_NewProject needs to be made exception safe
  • Loading branch information
ioan-chera committed Nov 6, 2023
1 parent 3ee2b95 commit 869f244
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class Instance
// MAIN
bool Main_ConfirmQuit(const char *action) const;
fs::path Main_FileOpFolder() const;
void Main_LoadResources(const LoadingData &loading);
void Main_LoadResources(const LoadingData &loading) noexcept(false);

// R_RENDER
void Render3D_CB_Copy() ;
Expand Down Expand Up @@ -399,7 +399,7 @@ class Instance
void LoadVertices(const Wad_file *load_wad);
bool M_ExportMap();
void Navigate2D();
void Project_ApplyChanges(const UI_ProjectSetup::Result &result);
void Project_ApplyChanges(const UI_ProjectSetup::Result &result) noexcept(false);
tl::optional<fs::path> Project_AskFile() const;
void SaveBehavior();
void SaveHeader(const SString &level);
Expand Down
4 changes: 2 additions & 2 deletions src/WadData.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const Lump_c *MasterDir::findFirstSpriteLump(const SString &stem) const
return result;
}

void WadData::W_LoadPalette()
void WadData::W_LoadPalette() noexcept(false)
{
const Lump_c *lump = master.findGlobalLump("PLAYPAL");
if(!lump)
Expand All @@ -62,7 +62,7 @@ void WadData::W_LoadPalette()
images.IM_ResetDummyTextures();
}

void WadData::reloadResources(const std::shared_ptr<Wad_file> &gameWad, const ConfigData &config, const std::vector<std::shared_ptr<Wad_file>> &resourceWads)
void WadData::reloadResources(const std::shared_ptr<Wad_file> &gameWad, const ConfigData &config, const std::vector<std::shared_ptr<Wad_file>> &resourceWads) noexcept(false)
{
// reset the master directory
WadData newWad = *this;
Expand Down
4 changes: 2 additions & 2 deletions src/WadData.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,14 @@ struct WadData
return const_cast<Img_c *>(getSprite(config, type, loading));
}

void reloadResources(const std::shared_ptr<Wad_file> &gameWad, const ConfigData &config, const std::vector<std::shared_ptr<Wad_file>> &resourceWads);
void reloadResources(const std::shared_ptr<Wad_file> &gameWad, const ConfigData &config, const std::vector<std::shared_ptr<Wad_file>> &resourceWads) noexcept(false);

ImageSet images;
Palette palette;
MasterDir master;

private:
void W_LoadPalette();
void W_LoadPalette() noexcept(false);
void W_LoadColormap()
{
palette.loadColormap(master.findGlobalLump("COLORMAP"));
Expand Down
6 changes: 3 additions & 3 deletions src/m_loadsave.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ tl::optional<fs::path> Instance::Project_AskFile() const
}


void Instance::Project_ApplyChanges(const UI_ProjectSetup::Result &result)
void Instance::Project_ApplyChanges(const UI_ProjectSetup::Result &result) noexcept(false)
{
// grab the new information
LoadingData loading = loaded;
Expand Down Expand Up @@ -194,9 +194,9 @@ void Instance::CMD_ManageProject()
Project_ApplyChanges(*result);
}
}
catch(const ParseException &e)
catch(const std::runtime_error &e)
{
DLG_ShowError(false, "Error reading configuration file: %s", e.what());
DLG_ShowError(false, "Error managing project: %s", e.what());
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ static void readPortInfo(std::unordered_map<SString, SString> &parseVars, Loadin
// open all wads in the master directory.
// read important content from the wads (palette, textures, etc).
//
void Instance::Main_LoadResources(const LoadingData &loading)
void Instance::Main_LoadResources(const LoadingData &loading) noexcept(false)
{
ConfigData config;
std::vector<std::shared_ptr<Wad_file>> resourceWads;
Expand Down

0 comments on commit 869f244

Please sign in to comment.