Commit 41c0868c authored by Cyril Deguet's avatar Cyril Deguet

* generic_window.cpp: register window visibility variables in

 the var manager, to avoid a crash at exit when an expression
 'not window.isVisible' is used in a skin.
parent 895d129f
......@@ -25,6 +25,7 @@
#include "generic_window.hpp"
#include "os_window.hpp"
#include "os_factory.hpp"
#include "var_manager.hpp"
#include "../events/evt_refresh.hpp"
......@@ -32,7 +33,7 @@ GenericWindow::GenericWindow( intf_thread_t *pIntf, int left, int top,
bool dragDrop, bool playOnDrop,
GenericWindow *pParent ):
SkinObject( pIntf ), m_left( left ), m_top( top ), m_width( 0 ),
m_height( 0 ), m_varVisible( pIntf )
m_height( 0 ), m_pVarVisible( NULL )
{
// Get the OSFactory
OSFactory *pOsFactory = OSFactory::instance( getIntf() );
......@@ -48,14 +49,18 @@ GenericWindow::GenericWindow( intf_thread_t *pIntf, int left, int top,
m_pOsWindow = pOsFactory->createOSWindow( *this, dragDrop, playOnDrop,
pOSParent );
// Create the visibility variable and register it in the manager
m_pVarVisible = new VarBoolImpl( pIntf );
VarManager::instance( pIntf )->registerVar( VariablePtr( m_pVarVisible ) );
// Observe the visibility variable
m_varVisible.addObserver( this );
m_pVarVisible->addObserver( this );
}
GenericWindow::~GenericWindow()
{
m_varVisible.delObserver( this );
m_pVarVisible->delObserver( this );
if( m_pOsWindow )
{
......@@ -74,13 +79,13 @@ void GenericWindow::processEvent( EvtRefresh &rEvtRefresh )
void GenericWindow::show() const
{
m_varVisible.set( true );
m_pVarVisible->set( true );
}
void GenericWindow::hide() const
{
m_varVisible.set( false );
m_pVarVisible->set( false );
}
......@@ -124,7 +129,7 @@ void GenericWindow::toggleOnTop( bool onTop ) const
void GenericWindow::onUpdate( Subject<VarBool, void*> &rVariable, void*arg )
{
if( m_varVisible.get() )
if( m_pVarVisible->get() )
{
innerShow();
}
......
......@@ -76,7 +76,7 @@ class GenericWindow: public SkinObject, public Observer<VarBool, void*>
int getHeight() const { return m_height; }
/// Give access to the visibility variable
VarBool &getVisibleVar() { return m_varVisible; }
VarBool &getVisibleVar() { return *m_pVarVisible; }
/// Window type, mainly useful when overloaded (for VoutWindow)
virtual string getType() const { return "Generic"; }
......@@ -119,7 +119,7 @@ class GenericWindow: public SkinObject, public Observer<VarBool, void*>
/// OS specific implementation
OSWindow *m_pOsWindow;
/// Variable for the visibility of the window
mutable VarBoolImpl m_varVisible;
mutable VarBoolImpl *m_pVarVisible;
/// Method called when the observed variable is modified
virtual void onUpdate( Subject<VarBool, void*> &rVariable , void*);
......
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