improve error handling when starting the GUI thread

This commit is contained in:
Fischlurch 2009-01-15 15:16:45 +01:00
parent 7d19d19549
commit 054c652571
4 changed files with 28 additions and 12 deletions

View file

@ -60,18 +60,18 @@ namespace gui {
: theGUI_("lumieraorg_Gui", 1, 1, "lumieraorg_GuiStarterPlugin") // load GuiStarterPlugin : theGUI_("lumieraorg_Gui", 1, 1, "lumieraorg_GuiStarterPlugin") // load GuiStarterPlugin
{ {
ASSERT (theGUI_); 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()); throw lumiera::error::Fatal("failed to bring up GUI",lumiera_error());
} }
~GuiRunner () { } ~GuiRunner () { }
void kickOff (Subsys::SigTerm& terminationHandle) bool kickOff (Subsys::SigTerm& terminationHandle)
{ {
theGUI_->kickOff (reinterpret_cast<void*> (&terminationHandle)); return theGUI_->kickOff (reinterpret_cast<void*> (&terminationHandle));
} }
}; };

View file

@ -44,6 +44,8 @@ extern "C" {
#include "common/interface.h" #include "common/interface.h"
} }
#include <boost/noncopyable.hpp>
namespace gui { namespace gui {
@ -69,6 +71,7 @@ namespace gui {
* *
*/ */
class GuiFacade class GuiFacade
: boost::noncopyable
{ {
public: public:
@ -91,7 +94,7 @@ namespace gui {
* @internal this function is invoked automatically during the GUI * @internal this function is invoked automatically during the GUI
* loading and startup process. Don't call it manually. * loading and startup process. Don't call it manually.
*/ */
virtual void kickOff (lumiera::Subsys::SigTerm&) =0; virtual bool kickOff (lumiera::Subsys::SigTerm&) =0;
protected: protected:
@ -100,7 +103,7 @@ namespace gui {
/** interface of the GuiStarterPlugin */ /** interface of the GuiStarterPlugin */
LUMIERA_INTERFACE_DECLARE (lumieraorg_Gui, 1, LUMIERA_INTERFACE_DECLARE (lumieraorg_Gui, 1,
LUMIERA_INTERFACE_SLOT (void, kickOff, (void*)) LUMIERA_INTERFACE_SLOT (bool, kickOff, (void*))
); );

View file

@ -70,6 +70,7 @@ using std::string;
using lib::Thread; using lib::Thread;
using std::tr1::bind; using std::tr1::bind;
using lumiera::Subsys; using lumiera::Subsys;
using lumiera::error::LUMIERA_ERROR_STATE;
using gui::LUMIERA_INTERFACE_INAME(lumieraorg_Gui, 1); using gui::LUMIERA_INTERFACE_INAME(lumieraorg_Gui, 1);
@ -77,7 +78,7 @@ namespace gui {
namespace { // implementation details namespace { // implementation details
/** /******************************************************************************
* Implement the necessary steps for actually making the Lumiera Gui available. * 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. * Open the business interface(s) and start up the GTK GUI main event loop.
*/ */
@ -133,10 +134,22 @@ namespace gui {
} // (End) impl details } // (End) impl details
void
bool
kickOff (Subsys::SigTerm& terminationHandle) kickOff (Subsys::SigTerm& terminationHandle)
{
try
{ {
Thread ("GUI-Main", bind (&runGUI, terminationHandle)); 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 } // namespace gui
@ -226,9 +239,9 @@ extern "C" { /* ================== define an lumieraorg_Gui instance ===========
, NULL /* on open */ , NULL /* on open */
, NULL /* on close */ , NULL /* on close */
, LUMIERA_INTERFACE_INLINE (kickOff, "\255\142\006\244\057\170\152\312\301\372\220\323\230\026\200\065", , 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));
} }
) )
) )