|
Greetings to all. I cannot solve a problem of use UserData in some Operator Callback Functions.
In <> _Init () Callback, I initialize structure as it is specified in SDK:
class CData
{ public:
LONG data; };
...... XSIPLUGINCALLBACK CStatus OperNameCPP1_Init( CRef& in_ctxt )
{
OperatorContext ctxt( in_ctxt ) ;
CData* p = new CData;
p->data = 123;
CValue cval = (CValue::siPtrType) p;
ctxt.PutUserData( cval ) ;
return CStatus::OK; }
In <> _Update () Callback, I use this structure, and I change data:
XSIPLUGINCALLBACK CStatus OperNameCPP1_Update( CRef& in_ctxt )
{
OperatorContext ctxt( in_ctxt ) ;
CData* p;
CValue cval = ctxt.GetUserData()
p = (CData*)(CValue::siPtrType) cval;
Application().LogMessage(L"value user is: "+CValue( p->data ) )
p->data++;
return CStatus::OK; }
- And all works perfectly.
But at attempt to use this structure and to change data in
<> _Define () Callback or <> _PPGEvent Callback - XSI is crashing.
XSIPLUGINCALLBACK CStatus OperNameCPP1_PPGEvent( CRef& in_ctxt )
{
PPGEventContext ctxt( in_ctxt ) ;
//OperatorContext ctxtOp( in_ctxt ) [b]- a'm trying this[/b]
//Context ctxtOp2( in_ctxt ) [b]-and a'm trying this[/b]
PPGEventContext::PPGEvent eventID = ctxt.GetEventID() ;
if ( eventID == PPGEventContext::siButtonClicked )
{
CData* p=nullptr;
CValue cval = ctxt.GetUserData()
p = (CData*)(CValue::siPtrType) cval;
p->data++; [b]// - Crash from this line !!!![/b]
}
}
In what there can be a reason? I tried to write down in UserData not the structure index, in usual data CValue (), but also they do not write/read in <> _Define () and <> _PPGEvent Callbacks
|