summaryrefslogtreecommitdiff
path: root/comIvy
diff options
context:
space:
mode:
Diffstat (limited to 'comIvy')
-rw-r--r--comIvy/Expression.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/comIvy/Expression.cpp b/comIvy/Expression.cpp
index 9a856a7..9287bae 100644
--- a/comIvy/Expression.cpp
+++ b/comIvy/Expression.cpp
@@ -12,13 +12,28 @@ char * ConvBSTR( BSTR str );
BSTR ConvCSTR( const char *str );
// CExpression
-
+STDMETHODIMP CExpression::Bind(char* regex, CBus* _bus)
+{
+ if ( !_bus ) return E_FAIL;
+ bus = _bus;
+ bus->AddRef();
+ if ( id != -1 )
+ return E_FAIL;
+ if ( bus->bus )
+ id = bus->bus->BindMsg( regex, this );
+ else return E_FAIL;
+ return S_OK;
+}
STDMETHODIMP CExpression::Unbind(void)
{
if ( !bus ) return E_FAIL;
- if ( bus->bus )
+ if ( bus->bus && id != -1 )
+ {
bus->bus->UnbindMsg( id );
+ id = -1;
+ }
+ else return E_FAIL;
bus->Release();
return S_OK;
}
@@ -59,7 +74,8 @@ CExpression::CExpression()
}
CExpression::~CExpression()
{
- Unbind();
+ if ( id != -1 )
+ Unbind();
id = -1;
bus = 0;
ATLTRACE("CExpression destroyed\n");