mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-10 09:50:17 +02:00
Merge pull request #1185 from Nordsoft91/editor-crash
Fix editor crashes [1.1]
This commit is contained in:
commit
b26c874446
@ -308,8 +308,9 @@ TObjectTypeHandler CObjectClassesHandler::getHandlerFor(si32 type, si32 subtype)
|
|||||||
if (objects.at(type)->subObjects.count(subtype))
|
if (objects.at(type)->subObjects.count(subtype))
|
||||||
return objects.at(type)->subObjects.at(subtype);
|
return objects.at(type)->subObjects.at(subtype);
|
||||||
}
|
}
|
||||||
logGlobal->error("Failed to find object of type %d:%d", type, subtype);
|
std::string errorString = "Failed to find object of type " + std::to_string(type) + "::" + std::to_string(subtype);
|
||||||
throw std::runtime_error("Object type handler not found");
|
logGlobal->error(errorString);
|
||||||
|
throw std::runtime_error(errorString);
|
||||||
}
|
}
|
||||||
|
|
||||||
TObjectTypeHandler CObjectClassesHandler::getHandlerFor(std::string scope, std::string type, std::string subtype) const
|
TObjectTypeHandler CObjectClassesHandler::getHandlerFor(std::string scope, std::string type, std::string subtype) const
|
||||||
@ -325,8 +326,9 @@ TObjectTypeHandler CObjectClassesHandler::getHandlerFor(std::string scope, std::
|
|||||||
return object->subObjects.at(subId);
|
return object->subObjects.at(subId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logGlobal->error("Failed to find object of type %s::%s", type, subtype);
|
std::string errorString = "Failed to find object of type " + type + "::" + subtype;
|
||||||
throw std::runtime_error("Object type handler not found");
|
logGlobal->error(errorString);
|
||||||
|
throw std::runtime_error(errorString);
|
||||||
}
|
}
|
||||||
|
|
||||||
TObjectTypeHandler CObjectClassesHandler::getHandlerFor(CompoundMapObjectID compoundIdentifier) const
|
TObjectTypeHandler CObjectClassesHandler::getHandlerFor(CompoundMapObjectID compoundIdentifier) const
|
||||||
|
@ -256,6 +256,8 @@ CMap::CMap()
|
|||||||
|
|
||||||
CMap::~CMap()
|
CMap::~CMap()
|
||||||
{
|
{
|
||||||
|
getEditManager()->getUndoManager().clearAll();
|
||||||
|
|
||||||
if(terrain)
|
if(terrain)
|
||||||
{
|
{
|
||||||
for(int z = 0; z < levels(); z++)
|
for(int z = 0; z < levels(); z++)
|
||||||
|
BIN
mapeditor/icons/edit-redo.png
Normal file
BIN
mapeditor/icons/edit-redo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
BIN
mapeditor/icons/edit-undo.png
Normal file
BIN
mapeditor/icons/edit-undo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
@ -172,11 +172,22 @@ void TownBulidingsWidget::addBuildings(const CTown & ctown)
|
|||||||
std::set<BuildingID> TownBulidingsWidget::getBuildingsFromModel(int modelColumn, Qt::CheckState checkState)
|
std::set<BuildingID> TownBulidingsWidget::getBuildingsFromModel(int modelColumn, Qt::CheckState checkState)
|
||||||
{
|
{
|
||||||
std::set<BuildingID> result;
|
std::set<BuildingID> result;
|
||||||
for(int i = 0; i < model.rowCount(); ++i)
|
std::vector<QModelIndex> stack;
|
||||||
|
stack.push_back(QModelIndex());
|
||||||
|
while(!stack.empty())
|
||||||
{
|
{
|
||||||
if(auto * item = model.item(i, modelColumn))
|
auto pindex = stack.back();
|
||||||
if(item->checkState() == checkState)
|
stack.pop_back();
|
||||||
result.emplace(item->data(Qt::UserRole).toInt());
|
for(int i = 0; i < model.rowCount(pindex); ++i)
|
||||||
|
{
|
||||||
|
QModelIndex index = model.index(i, modelColumn, pindex);
|
||||||
|
if(auto * item = model.itemFromIndex(index))
|
||||||
|
if(item->checkState() == checkState)
|
||||||
|
result.emplace(item->data(Qt::UserRole).toInt());
|
||||||
|
index = model.index(i, 0, pindex); //children are linked to first column of the model
|
||||||
|
if(model.hasChildren(index))
|
||||||
|
stack.push_back(index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -123,6 +123,9 @@
|
|||||||
<addaction name="actionOpen"/>
|
<addaction name="actionOpen"/>
|
||||||
<addaction name="actionSave"/>
|
<addaction name="actionSave"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionUndo"/>
|
||||||
|
<addaction name="actionRedo"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
<addaction name="actionLevel"/>
|
<addaction name="actionLevel"/>
|
||||||
<addaction name="actionGrid"/>
|
<addaction name="actionGrid"/>
|
||||||
<addaction name="actionPass"/>
|
<addaction name="actionPass"/>
|
||||||
@ -1010,6 +1013,9 @@
|
|||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionPlayers_settings">
|
<action name="actionPlayers_settings">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Players settings</string>
|
<string>Players settings</string>
|
||||||
</property>
|
</property>
|
||||||
@ -1018,6 +1024,10 @@
|
|||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset>
|
||||||
|
<normaloff>icons:edit-undo.png</normaloff>icons:edit-undo.png</iconset>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Undo</string>
|
<string>Undo</string>
|
||||||
</property>
|
</property>
|
||||||
@ -1035,6 +1045,10 @@
|
|||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset>
|
||||||
|
<normaloff>icons:edit-redo.png</normaloff>icons:edit-redo.png</iconset>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Redo</string>
|
<string>Redo</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -214,6 +214,7 @@ void MapController::setMap(std::unique_ptr<CMap> cmap)
|
|||||||
main->enableRedo(allowRedo);
|
main->enableRedo(allowRedo);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
_map->getEditManager()->getUndoManager().clearAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapController::sceneForceUpdate()
|
void MapController::sceneForceUpdate()
|
||||||
|
@ -37,8 +37,10 @@ WindowNewMap::WindowNewMap(QWidget *parent) :
|
|||||||
show();
|
show();
|
||||||
|
|
||||||
//setup initial parameters
|
//setup initial parameters
|
||||||
mapGenOptions.setWidth(ui->widthTxt->text().toInt());
|
int width = ui->widthTxt->text().toInt();
|
||||||
mapGenOptions.setHeight(ui->heightTxt->text().toInt());
|
int height = ui->heightTxt->text().toInt();
|
||||||
|
mapGenOptions.setWidth(width ? width : 1);
|
||||||
|
mapGenOptions.setHeight(height ? height : 1);
|
||||||
bool twoLevel = ui->twoLevelCheck->isChecked();
|
bool twoLevel = ui->twoLevelCheck->isChecked();
|
||||||
mapGenOptions.setHasTwoLevels(twoLevel);
|
mapGenOptions.setHasTwoLevels(twoLevel);
|
||||||
updateTemplateList();
|
updateTemplateList();
|
||||||
|
Loading…
Reference in New Issue
Block a user