Skip to content

Commit

Permalink
#5231: Fix Jump to Object algorithm crashing
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Jun 29, 2020
1 parent 244e6aa commit a28c732
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion radiant/camera/CamWnd.cpp
Expand Up @@ -494,7 +494,7 @@ void CamWnd::jumpToObject(SelectionTest& selectionTest) {

// Focus the view at the center of the found AABB
// Set the camera and the views to the given point
GlobalCameraManager().focusCamera(found.origin, getCameraAngles());
GlobalCameraView().focusCamera(found.origin, getCameraAngles());
GlobalXYWndManager().setOrigin(found.origin);
}
}
Expand Down
21 changes: 14 additions & 7 deletions radiant/camera/GlobalCamera.cpp
Expand Up @@ -85,31 +85,38 @@ void GlobalCameraManager::registerCommands()
GlobalEventManager().addKeyEvent("CameraMoveDown", std::bind(&GlobalCameraManager::onFreelookMoveDownKey, this, std::placeholders::_1));
}

CamWndPtr GlobalCameraManager::getActiveCamWnd() {
CamWndPtr GlobalCameraManager::getActiveCamWnd()
{
// Sanity check in debug builds
assert(_cameras.find(_activeCam) != _cameras.end());
assert(_activeCam == -1 || _cameras.find(_activeCam) != _cameras.end());

if (_activeCam == -1) return CamWndPtr();

CamWndPtr cam = _cameras[_activeCam].lock();

if (cam == NULL) {
if (!cam)
{
// Camera is not used anymore, remove it
removeCamWnd(_activeCam);

// Find a new active camera
if (!_cameras.empty()) {
if (!_cameras.empty())
{
_activeCam = _cameras.begin()->first;
}
else {
else
{
// No more cameras available
_activeCam = -1;
}

if (_activeCam != -1) {
if (_activeCam != -1)
{
cam = _cameras[_activeCam].lock();
}
}

return (_activeCam != -1) ? cam : CamWndPtr();
return cam;
}

CamWndPtr GlobalCameraManager::createCamWnd(wxWindow* parent)
Expand Down

0 comments on commit a28c732

Please sign in to comment.