Commit c0c3218a authored by Serrière Guillaume's avatar Serrière Guillaume

Add popup on initilization error.

Signed-off-by: default avatarSerrière Guillaume <guillaume.serriere@inria.fr>
parent a593e7bb
......@@ -947,6 +947,173 @@ Contributions also from :
<action-widget response="0">dialog_error_popup-button_ok</action-widget>
</action-widgets>
</object>
<object class="GtkDialog" id="dialog_init_error_popup">
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="title" translatable="yes"> </property>
<property name="window_position">center-on-parent</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog_init-vbox21">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog_init-action_area21">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="dialog_init_error_popup-button_continue">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<child>
<object class="GtkHBox" id="init_error_hbox5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImage" id="init_error_image3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-media-play</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="init_error_label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Continue</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="dialog_init_error_popup-button_stop">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<accelerator key="Return" signal="clicked"/>
<accelerator key="KP_Enter" signal="clicked"/>
<child>
<object class="GtkHBox" id="init_error_hbox6">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImage" id="init_error_image4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-stop</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="init_error_label4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Stop</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkTable" id="init_error_table5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="n_rows">1</property>
<property name="n_columns">2</property>
<property name="column_spacing">8</property>
<property name="row_spacing">8</property>
<child>
<object class="GtkLabel" id="init_error_unsaved_scenario_global-label_first_text1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">&lt;b&gt;One or more errors have occured during the initialization of the scenario.
Do you want to continue the execution?&lt;/b&gt;</property>
<property name="use_markup">True</property>
<property name="justify">center</property>
<property name="wrap">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
</packing>
</child>
<child>
<object class="GtkImage" id="init_error_unsaved_scenario_global-image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-dialog-warning</property>
<property name="icon-size">6</property>
</object>
<packing>
<property name="bottom_attach">1</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="1">dialog_init_error_popup-button_continue</action-widget>
<action-widget response="0">dialog_init_error_popup-button_stop</action-widget>
</action-widgets>
</object>
<object class="GtkDialog" id="dialog_running_scenario">
<property name="can_focus">False</property>
<property name="border_width">5</property>
......@@ -3248,6 +3415,28 @@ on Warnings and Errors</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolItem" id="Init_alert">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkCheckButton" id="openvibe-messages_init_alert">
<property name="label" translatable="yes">Show pop-up
on initilization failure?</property>
<property name="visible">True</property>
<property name="active">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="xalign">0.5</property>
<property name="draw_indicator">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
......@@ -3392,6 +3581,7 @@ on Warnings and Errors</property>
<property name="position">5</property>
</packing>
</child>
</object>
</child>
</object>
......
......@@ -326,6 +326,7 @@ static void window_menu_check_item_toggled_cb(GtkCheckMenuItem* pCheckMenuItem,
str[i]-=32;
return str;
}
static gboolean box_algorithm_search_func(GtkTreeModel *model, GtkTreeIter *iter, gpointer pUserData)
{
CApplication* l_pApplication=static_cast<CApplication*>(pUserData);
......@@ -647,6 +648,7 @@ CApplication::CApplication(const IKernelContext& rKernelContext)
,m_f64LastTimeRefresh(0.0)
,m_bIsQuitting(false)
,m_i32CurrentScenarioPage(-1)
,m_pInitAlert(NULL)
,m_eReplayMode(EReplayMode_None)
{
m_pPluginManager=&m_rKernelContext.getPluginManager();
......@@ -772,6 +774,8 @@ void CApplication::initialize(ECommandLineFlag eCommandLineFlags)
g_signal_connect(G_OBJECT(m_pScenarioNotebook), "page-reordered", G_CALLBACK(reorder_scenario_cb), this);
m_pResourceNotebook=GTK_NOTEBOOK(gtk_builder_get_object(m_pBuilderInterface, "openvibe-resource_notebook"));
m_pInitAlert = GTK_TOGGLE_BUTTON(gtk_builder_get_object(m_pBuilderInterface, "openvibe-messages_init_alert"));
// Creates an empty scnenario
gtk_notebook_remove_page(m_pScenarioNotebook, 0);
//newScenarioCB();
......@@ -1865,7 +1869,9 @@ OpenViBE::boolean CApplication::createPlayer(void)
CIdentifier l_oPlayerIdentifier=l_pCurrentInterfacedScenario->m_oPlayerIdentifier;
l_pCurrentInterfacedScenario->m_pPlayer=&m_rKernelContext.getPlayerManager().getPlayer(l_oPlayerIdentifier);
l_pCurrentInterfacedScenario->m_pPlayer->setScenario(l_oScenarioIdentifier);
if(!l_pCurrentInterfacedScenario->m_pPlayer->initialize())
EPlayerReturnCode l_eCode = l_pCurrentInterfacedScenario->m_pPlayer->initialize();
if(l_eCode == PlayerReturnCode_Failed)
{
m_rKernelContext.getLogManager() << LogLevel_Error << "Failed to initialize player\n";
l_pCurrentInterfacedScenario->m_oPlayerIdentifier = OV_UndefinedIdentifier;
......@@ -1873,6 +1879,28 @@ OpenViBE::boolean CApplication::createPlayer(void)
m_rKernelContext.getPlayerManager().releasePlayer(l_oPlayerIdentifier);
return false;
}
else if(l_eCode == PlayerReturnCode_BoxInitializationFailed){
gint res = 1;
if(gtk_toggle_button_get_active(m_pInitAlert))
{
::GtkBuilder* l_pBuilder=gtk_builder_new(); // glade_xml_new(OVD_GUI_File, "about", NULL);
gtk_builder_add_from_file(l_pBuilder, OVD_GUI_File, NULL);
gtk_builder_connect_signals(l_pBuilder, NULL);
::GtkWidget* l_pDialog=GTK_WIDGET(gtk_builder_get_object(l_pBuilder, "dialog_init_error_popup"));
res = gtk_dialog_run(GTK_DIALOG(l_pDialog));
gtk_widget_destroy(l_pDialog);
g_object_unref(l_pBuilder);
}
if(res == 0)
{
l_pCurrentInterfacedScenario->m_oPlayerIdentifier = OV_UndefinedIdentifier;
l_pCurrentInterfacedScenario->m_pPlayer=NULL;
m_rKernelContext.getPlayerManager().releasePlayer(l_oPlayerIdentifier);
return false;
}
}
l_pCurrentInterfacedScenario->m_ui64LastLoopTime=System::Time::zgetTime();
//set up idle function
......
......@@ -199,6 +199,8 @@ namespace OpenViBEDesigner
OpenViBE::boolean m_bIsQuitting;
OpenViBE::int32 m_i32CurrentScenarioPage;
::GtkToggleButton* m_pInitAlert;
std::vector < OpenViBEDesigner::CInterfacedScenario* > m_vInterfacedScenario;
// Keeps track of the used playing mode so the playback can be restarted in the same mode.
......
......@@ -76,12 +76,12 @@ boolean CPlayer::setScenario(
return m_oScheduler.setScenario(rScenarioIdentifier);;
}
boolean CPlayer::initialize(void)
EPlayerReturnCode CPlayer::initialize(void)
{
if(m_eStatus!=PlayerStatus_Uninitialized)
{
this->getLogManager() << LogLevel_Warning << "Trying to initialize an initialized player !\n";
return false;
return PlayerReturnCode_Failed;
}
this->getLogManager() << LogLevel_Trace << "Player initialize\n";
......@@ -120,15 +120,15 @@ boolean CPlayer::initialize(void)
this->getLogManager() << LogLevel_Trace << "Requesting add of local scenario config from " << l_sConfigPath << "\n";
m_pLocalConfigurationManager->addConfigurationFromFile( l_sConfigPath );
}
if(!m_oScheduler.initialize())
SchedulerInitializationCode l_eCode = m_oScheduler.initialize();
if(l_eCode == SchedulerInitialization_Failed)
{
this->getLogManager() << LogLevel_Error << "Scheduler initialization failed\n";
delete m_pLocalConfigurationManager;
m_pLocalConfigurationManager = NULL;
return false;
return PlayerReturnCode_Failed;
}
m_oBenchmarkChrono.reset(static_cast<uint32>(m_oScheduler.getFrequency()));
......@@ -136,7 +136,11 @@ boolean CPlayer::initialize(void)
m_ui64Lateness=0;
m_eStatus=PlayerStatus_Stop;
return true;
if(l_eCode == SchedulerInitialization_BoxInitializationFailed)
{
return PlayerReturnCode_BoxInitializationFailed;
}
return PlayerReturnCode_Sucess;
}
......
......@@ -24,7 +24,7 @@ namespace OpenViBE
virtual OpenViBE::boolean setScenario(
const OpenViBE::CIdentifier& rScenarioIdentifier);
virtual OpenViBE::boolean initialize(void);
virtual OpenViBE::Kernel::EPlayerReturnCode initialize(void);
virtual OpenViBE::boolean uninitialize(void);
virtual OpenViBE::boolean stop(void);
......
......@@ -238,28 +238,28 @@ boolean CScheduler::setFrequency(
//___________________________________________________________________//
// //
boolean CScheduler::initialize(void)
SchedulerInitializationCode CScheduler::initialize(void)
{
this->getLogManager() << LogLevel_Trace << "Scheduler initialize\n";
if(m_bIsInitialized)
{
this->getLogManager() << LogLevel_Warning << "Trying to initialize an intialized scheduler !\n";
return false;
return SchedulerInitialization_Failed;
}
m_pScenario=&getScenarioManager().getScenario(m_oScenarioIdentifier);
if(!m_pScenario)
{
this->getLogManager() << LogLevel_ImportantWarning << "Scenario " << m_oScenarioIdentifier << " does not exist !\n";
return false;
return SchedulerInitialization_Failed;
}
CBoxSettingModifierVisitor l_oBoxSettingModifierVisitor(&getKernelContext().getConfigurationManager());
if(!m_pScenario->acceptVisitor(l_oBoxSettingModifierVisitor))
{
this->getLogManager() << LogLevel_Error << "Scenario " << m_oScenarioIdentifier << " setting modification with acceptVisitor() failed\n";
return false;
return SchedulerInitialization_Failed;
}
CIdentifier l_oBoxIdentifier;
......@@ -300,13 +300,18 @@ boolean CScheduler::initialize(void)
m_vSimulatedBoxChrono[l_oBoxIdentifier].reset(static_cast<uint32>(m_ui64Frequency));
}
boolean l_bBoxInitialization = true;
for(map < pair < int32, CIdentifier >, CSimulatedBox* >::iterator itSimulatedBox=m_vSimulatedBox.begin(); itSimulatedBox!=m_vSimulatedBox.end(); itSimulatedBox++)
{
const IBox* l_pBox=m_pScenario->getBoxDetails(itSimulatedBox->first.second);
this->getLogManager() << LogLevel_Trace << "Scheduled box : id = " << itSimulatedBox->first.second << " priority = " << -itSimulatedBox->first.first << " name = " << l_pBox->getName() << "\n";
if(itSimulatedBox->second ) // we initialize regardless of mute so that we can bring the box back during the run (in theory...)
{
itSimulatedBox->second->initialize();
if(!itSimulatedBox->second->initialize())
{
l_bBoxInitialization = false;
}
}
}
......@@ -315,7 +320,11 @@ boolean CScheduler::initialize(void)
m_bIsInitialized=true;
m_oBenchmarkChrono.reset((System::uint32)m_ui64Frequency);
return true;
if(l_bBoxInitialization)
{
return SchedulerInitialization_Success;
}
return SchedulerInitialization_BoxInitializationFailed;
}
......
......@@ -12,6 +12,12 @@ namespace OpenViBE
{
namespace Kernel
{
enum SchedulerInitializationCode{
SchedulerInitialization_Success,
SchedulerInitialization_BoxInitializationFailed,
SchedulerInitialization_Failed
};
class CSimulatedBox;
class CChunk;
class CPlayer;
......@@ -28,7 +34,7 @@ namespace OpenViBE
virtual OpenViBE::boolean setFrequency(
const OpenViBE::uint64 ui64Frequency);
virtual OpenViBE::boolean initialize(void);
virtual SchedulerInitializationCode initialize(void);
virtual OpenViBE::boolean uninitialize(void);
virtual OpenViBE::boolean loop(void);
......
......@@ -759,6 +759,7 @@ boolean CSimulatedBox::initialize(void)
{
getLogManager() << LogLevel_ImportantWarning << "Box algorithm <" << m_pBox->getName() << "> has been deactivated because initialize() function returned error\n";
m_bSuspended=true;
return false;
}
}
catch (...)
......
......@@ -910,7 +910,7 @@ boolean CBox::setSettingValue(
void CBox::notifySettingChange(BoxEventMessageType eType, int32 i32FirstIndex, int32 i32SecondIndex)
{
if( m_bIsNotificationActive && m_bIsObserverNotificationActive)
if( m_bIsObserverNotificationActive)
{
BoxEventMessage l_oEvent;
l_oEvent.m_eType = eType;
......
......@@ -19,6 +19,13 @@ namespace OpenViBE
PlayerStatus_Forward,
};
enum EPlayerReturnCode
{
PlayerReturnCode_Sucess,
PlayerReturnCode_Failed,
PlayerReturnCode_BoxInitializationFailed
};
/**
* \class IPlayer
* \author Yann Renard (INRIA/IRISA)
......@@ -47,7 +54,7 @@ namespace OpenViBE
virtual OpenViBE::boolean setScenario(
const OpenViBE::CIdentifier& rScenarioIdentifier)=0;
virtual OpenViBE::boolean initialize(void)=0;
virtual EPlayerReturnCode initialize(void)=0;
virtual OpenViBE::boolean uninitialize(void)=0;
/**
......
......@@ -22,7 +22,6 @@ void CObservable::deleteObserver(IObserver *o)
for(std::vector<IObserver *>::iterator it = m_vObservers.begin(); it != m_vObservers.end() ; ++it)
{
if((*it) == o){
std::cout << "here" << std::endl;
m_vObservers.erase(it);
//We only suppress the first occurence, no need to continue
return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment