Fixed rtabmapviz exit without hard kill

This commit is contained in:
matlabbe
2016-03-17 16:36:44 -04:00
parent 9096c3d1d0
commit 9c2e87ea38
3 changed files with 11 additions and 14 deletions
+11 -2
View File
@@ -33,9 +33,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <rtabmap/utilite/ULogger.h>
#include <signal.h>
QApplication * app = 0;
void my_handler(int s){
ROS_INFO("rtabmapviz: ctrl-c catched! Exiting Qt app...");
QApplication::exit();
if(app)
{
QMetaObject::invokeMethod(app, "quit");
}
}
int main(int argc, char** argv)
@@ -47,6 +52,9 @@ int main(int argc, char** argv)
ros::init(argc, argv, "rtabmapviz");
app = new QApplication(argc, argv);
app->connect( app, SIGNAL( lastWindowClosed() ), app, SLOT( quit() ) );
GuiWrapper gui(argc, argv);
// Catch ctrl-c to close the gui
@@ -63,10 +71,11 @@ int main(int argc, char** argv)
ROS_INFO("rtabmapviz started.");
// Now wait for application to finish
int r = gui.exec();// MUST be called by the Main Thread
int r = app->exec();// MUST be called by the Main Thread
spinner.stop();
delete app;
ROS_INFO("rtabmapviz: All done! Closing...");
return r;
}