GuiStart: further streamlined the invocation code
due to investigating that Heisenbug, I understand the storage layout more clearly. It occured to me that there is no reason to copy the terminationHandler (functor) into an instance variable, since it is easily possible to keep all of the invocation and error handling confined within the scope of the run function, i.e. on stack. So the effective memory layout does not change, but the legibility of the code is improved, since we're able to remove the dtor and simplyfy the ctor and avoid most of the member fields.
This commit is contained in:
parent
2354c53a50
commit
cb31b145c3
2 changed files with 17 additions and 24 deletions
|
|
@ -63,8 +63,6 @@ namespace gui {
|
|||
throw lumiera::error::Fatal("failed to bring up GUI",lumiera_error());
|
||||
}
|
||||
|
||||
~GuiRunner () { }
|
||||
|
||||
|
||||
bool launchUI (Subsys::SigTerm& terminationHandle) override
|
||||
{
|
||||
|
|
|
|||
|
|
@ -89,24 +89,17 @@ namespace gui {
|
|||
*/
|
||||
struct GuiLifecycle
|
||||
{
|
||||
string error_;
|
||||
Subsys::SigTerm reportOnTermination_;
|
||||
DisplayService activateDisplayService_; ///////////////////////////TICKET #82 will go away once we have a real OutputSlot offered by the UI
|
||||
|
||||
GuiLifecycle (Subsys::SigTerm terminationHandler)
|
||||
: reportOnTermination_(terminationHandler)
|
||||
, activateDisplayService_() // opens the gui::Display facade interface
|
||||
GuiLifecycle ()
|
||||
: activateDisplayService_() // opens the gui::Display facade interface
|
||||
{ }
|
||||
|
||||
~GuiLifecycle ()
|
||||
{
|
||||
reportOnTermination_(&error_); // inform main thread that the GUI has been shut down.
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
run ()
|
||||
run (Subsys::SigTerm reportOnTermination)
|
||||
{
|
||||
string errorMsgBuff;
|
||||
try
|
||||
{
|
||||
int argc =0;
|
||||
|
|
@ -114,27 +107,29 @@ namespace gui {
|
|||
|
||||
// execute the GTK Event Loop____________
|
||||
GtkLumiera::application().main(argc, argv); /////////////TICKET #1048 : do not access GtkLumiera as singleton, rather just place it as local variable on the stack here
|
||||
|
||||
if (!lumiera_error_peek())
|
||||
return; // all went well, normal shutdown
|
||||
}
|
||||
} // all went well, regular shutdown
|
||||
|
||||
catch (lumiera::Error& problem)
|
||||
{
|
||||
error_ = problem.what();
|
||||
errorMsgBuff = problem.what();
|
||||
lumiera_error(); // clear error flag
|
||||
return;
|
||||
}
|
||||
catch (...){ }
|
||||
error_ = "unexpected error terminated the GUI.";
|
||||
return;
|
||||
catch (...)
|
||||
{
|
||||
errorMsgBuff = "unexpected error terminated the GUI.";
|
||||
}
|
||||
if (lumiera_error_peek())
|
||||
errorMsgBuff = string{lumiera_error()};
|
||||
|
||||
reportOnTermination(&errorMsgBuff); // inform main thread that the GUI has been shut down.
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
runGUI (Subsys::SigTerm reportTermination)
|
||||
runGUI (Subsys::SigTerm& reportOnTermination)
|
||||
{
|
||||
GuiLifecycle(reportTermination).run();
|
||||
GuiLifecycle{}.run (reportOnTermination);
|
||||
}
|
||||
|
||||
} // (End) impl details
|
||||
|
|
|
|||
Loading…
Reference in a new issue