Commit e8330066 authored by Erwan Tulou's avatar Erwan Tulou

skins2: fix boolean variables

skins2 expects notification to occur if and only if the variable really changes.

This patch fixes things for And and Or variables.
This fixes trac #4529
parent 8fd1f855
......@@ -46,7 +46,8 @@ void VarBoolImpl::set( bool value )
VarBoolAndBool::VarBoolAndBool( intf_thread_t *pIntf, VarBool &rVar1,
VarBool &rVar2 ):
VarBool( pIntf ), m_rVar1( rVar1 ), m_rVar2( rVar2 )
VarBool( pIntf ), m_rVar1( rVar1 ), m_rVar2( rVar2 ),
m_value( rVar1.get() && rVar2.get() )
{
m_rVar1.addObserver( this );
m_rVar2.addObserver( this );
......@@ -62,13 +63,18 @@ VarBoolAndBool::~VarBoolAndBool()
void VarBoolAndBool::onUpdate( Subject<VarBool> &rVariable, void *arg )
{
notify();
if( m_value != ( m_rVar1.get() && m_rVar2.get() ) )
{
m_value = ( m_rVar1.get() && m_rVar2.get() );
notify();
}
}
VarBoolOrBool::VarBoolOrBool( intf_thread_t *pIntf, VarBool &rVar1,
VarBool &rVar2 ):
VarBool( pIntf ), m_rVar1( rVar1 ), m_rVar2( rVar2 )
VarBool( pIntf ), m_rVar1( rVar1 ), m_rVar2( rVar2 ),
m_value( rVar1.get() || rVar2.get() )
{
m_rVar1.addObserver( this );
m_rVar2.addObserver( this );
......@@ -84,7 +90,11 @@ VarBoolOrBool::~VarBoolOrBool()
void VarBoolOrBool::onUpdate( Subject<VarBool> &rVariable , void*arg)
{
notify();
if( m_value != ( m_rVar1.get() || m_rVar2.get() ) )
{
m_value = ( m_rVar1.get() || m_rVar2.get() );
notify();
}
}
......
......@@ -94,7 +94,7 @@ class VarBoolAndBool: public VarBool, public Observer<VarBool>
public:
VarBoolAndBool( intf_thread_t *pIntf, VarBool &rVar1, VarBool &rVar2 );
virtual ~VarBoolAndBool();
virtual bool get() const { return m_rVar1.get() && m_rVar2.get(); }
virtual bool get() const { return m_value; }
// Called when one of the observed variables is changed
void onUpdate( Subject<VarBool> &rVariable, void* );
......@@ -102,6 +102,7 @@ public:
private:
/// Boolean variables
VarBool &m_rVar1, &m_rVar2;
bool m_value;
};
......@@ -111,7 +112,7 @@ class VarBoolOrBool: public VarBool, public Observer<VarBool>
public:
VarBoolOrBool( intf_thread_t *pIntf, VarBool &rVar1, VarBool &rVar2 );
virtual ~VarBoolOrBool();
virtual bool get() const { return m_rVar1.get() || m_rVar2.get(); }
virtual bool get() const { return m_value; }
// Called when one of the observed variables is changed
void onUpdate( Subject<VarBool> &rVariable, void* );
......@@ -119,6 +120,7 @@ public:
private:
/// Boolean variables
VarBool &m_rVar1, &m_rVar2;
bool m_value;
};
......
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