mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-04 02:41:19 +00:00
716eebe616
Fix terrain selection crash See merge request OpenMW/openmw!1165 (cherry picked from commitec4e3b04a7
)b84e41bd
Avoid storing ref, dynamic cast worldspacewidget for safetyd62ddc00
Use QPointer to detect object existence, less verbose debug messagescb42b528
Remove friend, make getEditMode public to allow editmode testing.4b148180
Restucture code08f7c73e
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();
|
|
}
|