improve error handling when starting the GUI thread
This commit is contained in:
parent
7d19d19549
commit
054c652571
4 changed files with 28 additions and 12 deletions
|
|
@ -60,18 +60,18 @@ namespace gui {
|
|||
: theGUI_("lumieraorg_Gui", 1, 1, "lumieraorg_GuiStarterPlugin") // load GuiStarterPlugin
|
||||
{
|
||||
ASSERT (theGUI_);
|
||||
this->kickOff (terminationHandle);
|
||||
bool res = this->kickOff (terminationHandle);
|
||||
|
||||
if (lumiera_error_peek())
|
||||
if (!res || lumiera_error_peek())
|
||||
throw lumiera::error::Fatal("failed to bring up GUI",lumiera_error());
|
||||
}
|
||||
|
||||
~GuiRunner () { }
|
||||
|
||||
|
||||
void kickOff (Subsys::SigTerm& terminationHandle)
|
||||
bool kickOff (Subsys::SigTerm& terminationHandle)
|
||||
{
|
||||
theGUI_->kickOff (reinterpret_cast<void*> (&terminationHandle));
|
||||
return theGUI_->kickOff (reinterpret_cast<void*> (&terminationHandle));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ extern "C" {
|
|||
#include "common/interface.h"
|
||||
}
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
|
||||
|
||||
namespace gui {
|
||||
|
||||
|
|
@ -69,6 +71,7 @@ namespace gui {
|
|||
*
|
||||
*/
|
||||
class GuiFacade
|
||||
: boost::noncopyable
|
||||
{
|
||||
public:
|
||||
|
||||
|
|
@ -91,7 +94,7 @@ namespace gui {
|
|||
* @internal this function is invoked automatically during the GUI
|
||||
* loading and startup process. Don't call it manually.
|
||||
*/
|
||||
virtual void kickOff (lumiera::Subsys::SigTerm&) =0;
|
||||
virtual bool kickOff (lumiera::Subsys::SigTerm&) =0;
|
||||
|
||||
|
||||
protected:
|
||||
|
|
@ -100,7 +103,7 @@ namespace gui {
|
|||
|
||||
/** interface of the GuiStarterPlugin */
|
||||
LUMIERA_INTERFACE_DECLARE (lumieraorg_Gui, 1,
|
||||
LUMIERA_INTERFACE_SLOT (void, kickOff, (void*))
|
||||
LUMIERA_INTERFACE_SLOT (bool, kickOff, (void*))
|
||||
);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ using std::string;
|
|||
using lib::Thread;
|
||||
using std::tr1::bind;
|
||||
using lumiera::Subsys;
|
||||
using lumiera::error::LUMIERA_ERROR_STATE;
|
||||
using gui::LUMIERA_INTERFACE_INAME(lumieraorg_Gui, 1);
|
||||
|
||||
|
||||
|
|
@ -77,7 +78,7 @@ namespace gui {
|
|||
|
||||
namespace { // implementation details
|
||||
|
||||
/**
|
||||
/******************************************************************************
|
||||
* Implement the necessary steps for actually making the Lumiera Gui available.
|
||||
* Open the business interface(s) and start up the GTK GUI main event loop.
|
||||
*/
|
||||
|
|
@ -133,10 +134,22 @@ namespace gui {
|
|||
} // (End) impl details
|
||||
|
||||
|
||||
void
|
||||
|
||||
|
||||
bool
|
||||
kickOff (Subsys::SigTerm& terminationHandle)
|
||||
{
|
||||
Thread ("GUI-Main", bind (&runGUI, terminationHandle));
|
||||
try
|
||||
{
|
||||
Thread ("GUI-Main", bind (&runGUI, terminationHandle));
|
||||
return true; // if we reach this line...
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
if (!lumiera_error_peek())
|
||||
LUMIERA_ERROR_SET (gui, STATE, "unexpected error when starting the GUI thread");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace gui
|
||||
|
|
@ -226,9 +239,9 @@ extern "C" { /* ================== define an lumieraorg_Gui instance ===========
|
|||
, NULL /* on open */
|
||||
, NULL /* on close */
|
||||
, LUMIERA_INTERFACE_INLINE (kickOff, "\255\142\006\244\057\170\152\312\301\372\220\323\230\026\200\065",
|
||||
void, (void* termSig),
|
||||
bool, (void* termSig),
|
||||
{
|
||||
gui::kickOff (*reinterpret_cast<Subsys::SigTerm *> (termSig));
|
||||
return gui::kickOff (*reinterpret_cast<Subsys::SigTerm *> (termSig));
|
||||
}
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ namespace lumiera {
|
|||
desc_ (description),
|
||||
cause_ ("")
|
||||
{
|
||||
lumiera_error_set (this->id_, description.c_str ());
|
||||
lumiera_error_set (this->id_, description.c_str ());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue