1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

avoid crash if any error in map

This commit is contained in:
Michael 2023-08-20 14:28:10 +02:00 committed by GitHub
parent e3a4c65100
commit 952ce3061b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -815,6 +815,9 @@ SelectionTab::CMapInfoTooltipBox::CMapInfoTooltipBox(std::string text, ResourceI
if(renderImage) if(renderImage)
mapLayerImages = createMinimaps(ResourceID(resource.getName(), EResType::MAP), IMAGE_SIZE); mapLayerImages = createMinimaps(ResourceID(resource.getName(), EResType::MAP), IMAGE_SIZE);
if(mapLayerImages.size() == 0)
renderImage = false;
pos = Rect(0, 0, 2 * BORDER + IMAGE_SIZE, 2000); pos = Rect(0, 0, 2 * BORDER + IMAGE_SIZE, 2000);
if(renderImage && mapLayerImages.size() > 1) if(renderImage && mapLayerImages.size() > 1)
pos.w += IMAGE_SIZE + BORDER; pos.w += IMAGE_SIZE + BORDER;
@ -889,7 +892,15 @@ std::vector<std::shared_ptr<IImage>> SelectionTab::CMapInfoTooltipBox::createMin
std::vector<std::shared_ptr<IImage>> ret = std::vector<std::shared_ptr<IImage>>(); std::vector<std::shared_ptr<IImage>> ret = std::vector<std::shared_ptr<IImage>>();
CMapService mapService; CMapService mapService;
std::unique_ptr<CMap> map = mapService.loadMap(resource); std::unique_ptr<CMap> map;
try
{
map = mapService.loadMap(resource);
}
catch (...)
{
return ret;
}
for(int i = 0; i < (map->twoLevel ? 2 : 1); i++) for(int i = 0; i < (map->twoLevel ? 2 : 1); i++)
{ {