QOsgWidget::~QOsgWidget() { // end the render thread and destroy the osgOpenglWidget std::this_thread::sleep_for(std::chrono::microseconds(1000)); mViewer->setDone(true); std::this_thread::sleep_for(std::chrono::microseconds(1000)); mViewer->stopThreading();
////////////////////////////////////////////////////////////////////////// /// without folowing post process, u will crash with the bellowing warning when: delete pWidget /// Warning: deleting still referenced object 000002433CA59BB0 of type 'class osg::Referenced * __ptr64' /// the final reference count was 1, memory corruption possible. /// /// the reason i guess is: /// the bellowing vars can not be automatically set to null when delete pWidget, because they does /// not belong to the pWidget, so u need to set them to null manually, otherwise when delete pWidget, /// the destructor of pWidget will try to free the bellowing vars, but their ref != 0 ///////////////////////////////// PART 1 ///////////////////////////////// mRoot = nullptr; mViewer = nullptr; camera = nullptr; trackball = nullptr; keyswitchManipulator = nullptr; //////////////////////////////////////////////////////////////////////////
delete pWidget; // call the destructor of the osgOpenglWidge }