In my device class I have defined a String property "IP_Addr" with the following "OnSet_IP_Addr" function:
if ( pure IP_Addr == value )
return;
pure IP_Addr = value;
notifyobservers ^IP_Addr;
The Generator for "OnSet_IP_Addr" is set to true.
In my C code I run the following piece of code to update the String property
char ipstr[IP4ADDR_STRLEN_MAX];
ip4addr_ntoa_r(&netif->ip_addr, ipstr, IP4ADDR_STRLEN_MAX); // code convert IP to character string
XString test = EwNewStringAnsi(ipstr);
SetIP(test);
Where SetIP is given by:
void SetIP(XString value)
{
RF_DriverDeviceClass__OnSetIP_Addr(DeviceObject, value );
}
With "RF_DriverDeviceClass__OnSetIP_Addr" the function that has been automatically generated by embedded wizard which is given by:
/* 'C' function for method : 'RF_Driver::DeviceClass.OnSetIP_Addr()' */
void RF_DriverDeviceClass_OnSetIP_Addr( RF_DriverDeviceClass _this, XString value )
{
if ( !EwCompString( _this->IP_Addr, value ))
return;
_this->IP_Addr = EwShareString( value );
EwNotifyRefObservers( EwNewRef( _this, RF_DriverDeviceClass_OnGetIP_Addr, RF_DriverDeviceClass_OnSetIP_Addr ),
0 );
}
When I run my C code the IP_Addr string in embedded wizard is updated as it is supposed to. However when I execute the code multiple times the GUI freezes and becomes unreponsive. For example when I run:
for (int i=0; i<10; i++)
{
char ipstr[5];
sprintf(ipstr,"%i",i);
XString test = EwNewStringAnsi(ipstr);
SetIP(test);
}
With a breakpoint on "SetIP" I see the screen being updated to 0, 1, and then it crashes.
Can you point out where my code fails and why ?