mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-30 12:32:36 +00:00
716eebe616
Fix terrain selection crash See merge request OpenMW/openmw!1165 (cherry picked from commit ec4e3b04a7b394acaaa8319b89ce1237e9d4d6e6) b84e41bd Avoid storing ref, dynamic cast worldspacewidget for safety d62ddc00 Use QPointer to detect object existence, less verbose debug messages cb42b528 Remove friend, make getEditMode public to allow editmode testing. 4b148180 Restucture code 08f7c73e Fix text
45 lines
1.1 KiB
C++
45 lines
1.1 KiB
C++
#include "commands.hpp"
|
|
|
|
#include <QPointer>
|
|
|
|
#include <components/debug/debuglog.hpp>
|
|
#include <components/esm/loadland.hpp>
|
|
|
|
#include "editmode.hpp"
|
|
#include "terrainselection.hpp"
|
|
#include "terrainshapemode.hpp"
|
|
#include "terraintexturemode.hpp"
|
|
#include "worldspacewidget.hpp"
|
|
|
|
CSVRender::DrawTerrainSelectionCommand::DrawTerrainSelectionCommand(WorldspaceWidget* worldspaceWidget, QUndoCommand* parent)
|
|
: mWorldspaceWidget(worldspaceWidget)
|
|
{ }
|
|
|
|
void CSVRender::DrawTerrainSelectionCommand::redo()
|
|
{
|
|
tryUpdate();
|
|
}
|
|
|
|
void CSVRender::DrawTerrainSelectionCommand::undo()
|
|
{
|
|
tryUpdate();
|
|
}
|
|
|
|
void CSVRender::DrawTerrainSelectionCommand::tryUpdate()
|
|
{
|
|
if (!mWorldspaceWidget)
|
|
{
|
|
Log(Debug::Verbose) << "Can't update terrain selection, no WorldspaceWidget found!";
|
|
return;
|
|
}
|
|
|
|
auto terrainMode = dynamic_cast<CSVRender::TerrainShapeMode*>(mWorldspaceWidget->getEditMode());
|
|
if (!terrainMode)
|
|
{
|
|
Log(Debug::Verbose) << "Can't update terrain selection in current EditMode";
|
|
return;
|
|
}
|
|
|
|
terrainMode->getTerrainSelection()->update();
|
|
}
|