mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-02 09:02:03 +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))
|
||||
return objects.at(type)->subObjects.at(subtype);
|
||||
}
|
||||
logGlobal->error("Failed to find object of type %d:%d", type, subtype);
|
||||
throw std::runtime_error("Object type handler not found");
|
||||
std::string errorString = "Failed to find object of type " + std::to_string(type) + "::" + std::to_string(subtype);
|
||||
logGlobal->error(errorString);
|
||||
throw std::runtime_error(errorString);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
logGlobal->error("Failed to find object of type %s::%s", type, subtype);
|
||||
throw std::runtime_error("Object type handler not found");
|
||||
std::string errorString = "Failed to find object of type " + type + "::" + subtype;
|
||||
logGlobal->error(errorString);
|
||||
throw std::runtime_error(errorString);
|
||||
}
|
||||
|
||||
TObjectTypeHandler CObjectClassesHandler::getHandlerFor(CompoundMapObjectID compoundIdentifier) const
|
||||
|
@ -256,6 +256,8 @@ CMap::CMap()
|
||||
|
||||
CMap::~CMap()
|
||||
{
|
||||
getEditManager()->getUndoManager().clearAll();
|
||||
|
||||
if(terrain)
|
||||
{
|
||||
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> 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))
|
||||
if(item->checkState() == checkState)
|
||||
result.emplace(item->data(Qt::UserRole).toInt());
|
||||
auto pindex = stack.back();
|
||||
stack.pop_back();
|
||||
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;
|
||||
|
@ -123,6 +123,9 @@
|
||||
<addaction name="actionOpen"/>
|
||||
<addaction name="actionSave"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionUndo"/>
|
||||
<addaction name="actionRedo"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionLevel"/>
|
||||
<addaction name="actionGrid"/>
|
||||
<addaction name="actionPass"/>
|
||||
@ -1010,6 +1013,9 @@
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionPlayers_settings">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Players settings</string>
|
||||
</property>
|
||||
@ -1018,6 +1024,10 @@
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:edit-undo.png</normaloff>icons:edit-undo.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Undo</string>
|
||||
</property>
|
||||
@ -1035,6 +1045,10 @@
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:edit-redo.png</normaloff>icons:edit-redo.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Redo</string>
|
||||
</property>
|
||||
|
@ -214,6 +214,7 @@ void MapController::setMap(std::unique_ptr<CMap> cmap)
|
||||
main->enableRedo(allowRedo);
|
||||
}
|
||||
);
|
||||
_map->getEditManager()->getUndoManager().clearAll();
|
||||
}
|
||||
|
||||
void MapController::sceneForceUpdate()
|
||||
|
@ -37,8 +37,10 @@ WindowNewMap::WindowNewMap(QWidget *parent) :
|
||||
show();
|
||||
|
||||
//setup initial parameters
|
||||
mapGenOptions.setWidth(ui->widthTxt->text().toInt());
|
||||
mapGenOptions.setHeight(ui->heightTxt->text().toInt());
|
||||
int width = ui->widthTxt->text().toInt();
|
||||
int height = ui->heightTxt->text().toInt();
|
||||
mapGenOptions.setWidth(width ? width : 1);
|
||||
mapGenOptions.setHeight(height ? height : 1);
|
||||
bool twoLevel = ui->twoLevelCheck->isChecked();
|
||||
mapGenOptions.setHasTwoLevels(twoLevel);
|
||||
updateTemplateList();
|
||||
|
Loading…
Reference in New Issue
Block a user