|
KiCad PCB EDA Suite
|
Safe initialization wrapper for the 3Dconnexion navlib SDK. More...
Go to the source code of this file.
Functions | |
| KICOMMON_API bool | SafeNavlibInit (const std::function< void()> &aInitFunc) |
| Attempt to run the given function, recovering from both C++ exceptions and abort() calls triggered by buggy third-party drivers. | |
| KICOMMON_API bool | NavlibDriverCrashed () |
| Returns true if a previous SafeNavlibInit call detected a driver crash. | |
Safe initialization wrapper for the 3Dconnexion navlib SDK.
The 3Dconnexion driver on some macOS versions calls std::terminate() during initialization (NlCreate), which cannot be caught by normal C++ exception handling. This wrapper installs a temporary SIGABRT handler to recover from the abort() that std::terminate() triggers.
Definition in file navlib_safe_init.h.
| KICOMMON_API bool NavlibDriverCrashed | ( | ) |
Returns true if a previous SafeNavlibInit call detected a driver crash.
Once the driver is known to be broken, all future SafeNavlibInit calls return false immediately without attempting initialization.
Definition at line 133 of file navlib_safe_init.cpp.
References s_driverCrashed().
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), NL_3D_VIEWER_PLUGIN::NL_3D_VIEWER_PLUGIN(), NL_FOOTPRINT_PROPERTIES_PLUGIN::NL_FOOTPRINT_PROPERTIES_PLUGIN(), NL_GERBVIEW_PLUGIN::NL_GERBVIEW_PLUGIN(), NL_PCBNEW_PLUGIN::NL_PCBNEW_PLUGIN(), NL_PL_EDITOR_PLUGIN::NL_PL_EDITOR_PLUGIN(), and NL_SCHEMATIC_PLUGIN::NL_SCHEMATIC_PLUGIN().
| KICOMMON_API bool SafeNavlibInit | ( | const std::function< void()> & | aInitFunc | ) |
Attempt to run the given function, recovering from both C++ exceptions and abort() calls triggered by buggy third-party drivers.
On macOS, temporarily installs a SIGABRT handler that uses siglongjmp to recover from abort(). On other platforms, wraps the call in a try/catch.
| aInitFunc | the initialization function to call |
Definition at line 52 of file navlib_safe_init.cpp.
References navlibSigAbrtHandler(), s_driverCrashed(), s_initMutex, s_jumpBuffer, and s_savedSigAbrtAction.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), NL_3D_VIEWER_PLUGIN_IMPL::Connect(), NL_PCBNEW_PLUGIN_IMPL::NL_PCBNEW_PLUGIN_IMPL(), NL_GERBVIEW_PLUGIN_IMPL::SetCanvas(), NL_PL_EDITOR_PLUGIN_IMPL::SetCanvas(), and NL_SCHEMATIC_PLUGIN_IMPL::SetCanvas().