gameoverhack / ofxOpenNI

Wrapper for OpenNI, NITE and SensorKinect
gingold.com.au
Other
246 stars 121 forks source link

Crash on Quit #26

Closed momo-the-monster closed 1 year ago

momo-the-monster commented 11 years ago

Example projects with User Generators often crash on quit for me - OS X 10.7.5 using latest from Master.

The issue is usually:

libXnVFeatures_1_5_2.dylib 'NACommonData::Update():

This line: 0xc26c55 movl (%eax), %eax

Triggers this: Thread 11: EXC_BAD_ACCESS (code=2, address=0x0)

Any ideas what's going on?

danomatika commented 11 years ago

Just put a sleep in testApp::exit() after calling stop() on the ofxOpenNI devices. That works for me. I imagine it's a typical threading issue where it takes a little bit of time to stop the thread but exit() is called right as the app quits, so things get deleted before the threads can finish.

I used sleep(2) for 2 seconds.

I'd suggest adding that to the addon itself as we do a similar thing in ofxKinect.

danomatika commented 11 years ago

Actually, disabling the quit on escape key and writing your own handler works better:

//--------------------------------------------------------------
void testApp::setup() {
...
    ofSetEscapeQuitsApp(false);
...
}
//--------------------------------------------------------------
void testApp::exit(){
    kinect.stop();
    OF_EXIT_APP(0);
}
//--------------------------------------------------------------
void testApp::keyPressed(int key){
    switch(key) {
        case 27:
            exit(); // call exit here to avoid thread error on app exit
            break;
    }
}
andiCR commented 10 years ago

Thanks for this, had this crash and this solution fixed it. Command Q will still crash it though, i hope there was an easier way.