mirror of
https://github.com/OpenMW/openmw.git
synced 2025-11-02 15:56:38 +00:00
Fix terrain selection crash See merge request OpenMW/openmw!1165 (cherry picked from commitec4e3b04a7)b84e41bdAvoid storing ref, dynamic cast worldspacewidget for safetyd62ddc00Use QPointer to detect object existence, less verbose debug messagescb42b528Remove friend, make getEditMode public to allow editmode testing.4b148180Restucture code08f7c73eFix text
44 lines
1.1 KiB
C++
44 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();
|
|
}
|