From e307d6c62a686a25aeb5e46d9bead8981f4f206b Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Tue, 8 Jul 2014 19:12:37 +0200 Subject: [PATCH] Fix crash when removing surface after releasing mouse outside window --- src/ofxBaseSurface.cpp | 5 +++++ src/ofxBaseSurface.h | 1 + src/ofxProjectionEditor.cpp | 12 ++++++++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/ofxBaseSurface.cpp b/src/ofxBaseSurface.cpp index 00768a6..67db7ef 100644 --- a/src/ofxBaseSurface.cpp +++ b/src/ofxBaseSurface.cpp @@ -64,4 +64,9 @@ void ofxBaseSurface::setTexture(ofTexture *texturePtr) ofTexture* ofxBaseSurface::getTexture() { return texture; +} + +ofTexture* ofxBaseSurface::getDefaultTexture() +{ + return &defaultTexture; } \ No newline at end of file diff --git a/src/ofxBaseSurface.h b/src/ofxBaseSurface.h index 744e926..300df97 100644 --- a/src/ofxBaseSurface.h +++ b/src/ofxBaseSurface.h @@ -26,6 +26,7 @@ public: void setTexture(ofTexture* texturePtr); ofTexture* getTexture(); + ofTexture* getDefaultTexture(); protected: ofMesh mesh; diff --git a/src/ofxProjectionEditor.cpp b/src/ofxProjectionEditor.cpp index eb9c050..2762f82 100644 --- a/src/ofxProjectionEditor.cpp +++ b/src/ofxProjectionEditor.cpp @@ -68,8 +68,16 @@ void ofxProjectionEditor::update(ofEventArgs &args) // update surface if one of the joints is being dragged for ( int i=0; iisDragged() || joints[i]->isSelected() ) { - // update vertex to new location - surfaceManager->getSelectedSurface()->setVertex(i, joints[i]->position); + + if ( surfaceManager->getSelectedSurface() != NULL ) { + // update vertex to new location + surfaceManager->getSelectedSurface()->setVertex(i, joints[i]->position); + } else { + // clear joints if there is no surface selected + // as the remove selected surface in the surface manager + // is not supposed to access joints here + joints.clear(); + } break; } }