diff --git a/Common/IPCHandler.cxx b/Common/IPCHandler.cxx index 8019d060..e4987f2c 100644 --- a/Common/IPCHandler.cxx +++ b/Common/IPCHandler.cxx @@ -35,11 +35,11 @@ IPCHandler::Attach(const char *path, short version, size_t message_size) m_Interface->SetKey("5A636Q488E.itksnap"); // Attach or create shared memory - AttachStatus status = ATTACHED; + AttachStatus status = IPC_ATTACHED; if (!m_Interface->Attach()) { m_Interface->Create(msize); - status = CREATED; + status = IPC_CREATED; } // Check if attached @@ -53,7 +53,7 @@ IPCHandler::Attach(const char *path, short version, size_t message_size) cerr << "Error attaching to or creating shared memory: " << strerror(errno) << endl; cerr << "This error may occur if a user is running two versions of ITK-SNAP" << endl; cerr << "Multisession support is disabled" << endl; - return ERROR; + return IPC_ERROR; } // Set the user data pointer diff --git a/Common/IPCHandler.h b/Common/IPCHandler.h index 905421f8..d87bfb00 100644 --- a/Common/IPCHandler.h +++ b/Common/IPCHandler.h @@ -32,7 +32,7 @@ class IPCHandler ~IPCHandler(); enum AttachStatus { - CREATED, ATTACHED, ERROR + IPC_CREATED, IPC_ATTACHED, IPC_ERROR }; /** diff --git a/GUI/Model/SynchronizationModel.cxx b/GUI/Model/SynchronizationModel.cxx index 0b4f3286..9fd3c66b 100644 --- a/GUI/Model/SynchronizationModel.cxx +++ b/GUI/Model/SynchronizationModel.cxx @@ -146,7 +146,7 @@ void SynchronizationModel::OnUpdate() // << endl; // If we attached to an existing session, then update from that session. - if (status == IPCHandler::ATTACHED) + if (status == IPCHandler::IPC_ATTACHED) { // std::cout << "Reading IPC state after main image update and exiting" << std::endl; ReadIPCState(false); diff --git a/GUI/Qt/Components/SNAPQApplication.cxx b/GUI/Qt/Components/SNAPQApplication.cxx index ddc2e7ac..0c66b532 100644 --- a/GUI/Qt/Components/SNAPQApplication.cxx +++ b/GUI/Qt/Components/SNAPQApplication.cxx @@ -55,23 +55,7 @@ void SNAPQApplication::setMainWindow(MainImageWindow *mainwin) bool SNAPQApplication::notify(QObject *object, QEvent *event) { - try - { - return QApplication::notify(object, event); - } - // catch (const std::exception &exc) - catch(...) - { - // Crash! - qCritical() << "Caught exception, exiting!!!"; - // ReportNonLethalException( - // NULL, exc, "Unexpected Error", "ITK-SNAP has crashed due to an unexpected error"); - - // Exit the application - QApplication::exit(-1); - - return false; - } + return QApplication::notify(object, event); } bool SNAPQApplication::event(QEvent *event) diff --git a/GUI/Qt/main.cxx b/GUI/Qt/main.cxx index 6afb2095..3d76868d 100644 --- a/GUI/Qt/main.cxx +++ b/GUI/Qt/main.cxx @@ -216,7 +216,7 @@ test_terminate_handler() QPushButton *openFolderButton = msgBox.addButton("Open Folder", QMessageBox::AcceptRole); // Add the "Close" button - msgBox.addButton(QMessageBox::Close); + msgBox.addButton("Close", QMessageBox::RejectRole); // Execute the message box and handle the button press msgBox.exec(); @@ -1224,15 +1224,7 @@ main(int argc, char *argv[]) } catch (std::exception &exc) { - qWarning() << "ITK-SNAP has crashed due to an uncaught exception: " << exc.what(); - QString backup_dir = BackupSegmentationToEmergencyFile(); - if (backup_dir.size()) - QMessageBox::critical( - nullptr, - "Uncaught exception", - QString("ITK-SNAP has crashed due to an uncaught exception. Your unsaved " - "segmentation files were saved to %1") - .arg(backup_dir)); + test_terminate_handler(); rc = -1; }