diff --git a/src/lib/platform/OSXScreen.mm b/src/lib/platform/OSXScreen.mm index 6c24a487..93bec0e9 100644 --- a/src/lib/platform/OSXScreen.mm +++ b/src/lib/platform/OSXScreen.mm @@ -39,6 +39,7 @@ #include "base/IEventQueue.h" #include "base/TMethodEventJob.h" #include "base/TMethodJob.h" +#include "synergy/DisplayInvalidException.h" #include #include @@ -107,7 +108,7 @@ OSXScreen::OSXScreen(IEventQueue* events, bool isPrimary, bool autoShowHideCurso { m_displayID = CGMainDisplayID(); if (!updateScreenShape(m_displayID, 0)) { - throw std::runtime_error ("failed to initialize screen shape"); + throw DisplayInvalidException ("failed to initialize screen shape"); } try { diff --git a/src/lib/synergy/App.cpp b/src/lib/synergy/App.cpp index 4c8c1808..8abf4dde 100644 --- a/src/lib/synergy/App.cpp +++ b/src/lib/synergy/App.cpp @@ -32,6 +32,7 @@ #include "ipc/IpcMessage.h" #include "ipc/Ipc.h" #include "base/EventQueue.h" +#include "DisplayInvalidException.h" #if SYSAPI_WIN32 #include "arch/win32/ArchMiscWindows.h" @@ -50,6 +51,7 @@ #include "platform/OSXDragSimulator.h" #endif + App* App::s_instance = nullptr; // @@ -125,6 +127,15 @@ App::run(int argc, char** argv) // using the exit(int) function! result = e.getCode(); } + catch (DisplayInvalidException& die) { + LOG((CLOG_CRIT "A display invalid exception error occurred: %s\n", die.what())); + // display invalid exceptions can occur when going to sleep. When this process exits, the + // UI will restart us instantly. We don't really want that behevior, so we quies for a bit + (void)sleep(10); + } + catch (std::runtime_error& re) { + LOG((CLOG_CRIT "A runtime error occurred: %s\n", re.what())); + } catch (std::exception& e) { LOG((CLOG_CRIT "An error occurred: %s\n", e.what())); } diff --git a/src/lib/synergy/DisplayInvalidException.h b/src/lib/synergy/DisplayInvalidException.h new file mode 100644 index 00000000..bdc32801 --- /dev/null +++ b/src/lib/synergy/DisplayInvalidException.h @@ -0,0 +1,39 @@ +/* + * synergy -- mouse and keyboard sharing utility + * Copyright (C) 2012-2018 Symless Ltd. + * Copyright (C) 2002 Chris Schoeneman + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file LICENSE that should have accompanied this file. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#ifndef SYNERGY_DISPLAYINVALIDEXCEPTION_H +#define SYNERGY_DISPLAYINVALIDEXCEPTION_H + + +#include +#include + +class DisplayInvalidException : public std::runtime_error { + public: + DisplayInvalidException(const char* msg): + std::runtime_error(msg) + { + } + + DisplayInvalidException(std::string msg): + std::runtime_error(msg) + { + } +}; + + +#endif //SYNERGY_DISPLAYINVALIDEXCEPTION_H