None of the examples in the docs show returning a shared_ptr, and most deal with simple types, not shared_ptr, so I'm not sure if what I'm doing is legal. I'd think there would be a way to do this for shared_ptrs to be useful in general, but maybe it isn't by returning them directly.
dummy() in the code below originally created the shared_ptr that is returned, but I was concerned that the problem may have been in the object going out of scope, so I changed it to use a passed in shared_ptr. Apologies that the test case is more complex than it could be.
This is tied to a button, and when I click the button in Gedi Quicktest it causes Gedi to generate a "ui Executable has stopped working".
Code: Select all
class First
{
public string sType() {return "First";}
};
class Second : First
{
public string sType() {return "Second";}
};
shared_ptr dummy(shared_ptr P)
{
shared_ptr T = P;
return T;
}
main(mapping event)
{
shared_ptr X = new Second();
DebugN(X.sType());
shared_ptr V = dummy(X);
DebugN(V.sType());
}
Code: Select all
Module: _QuickTest_
Panel: C:\\WinCC_OA_Proj\\testing\\panels\\test.pnl []
Object: 1 named: "PUSH_BUTTON2" of type: PUSH_BUTTON
Script: Clicked
Line: 14, Given datatype does not match with needed type 'First'
WCCOAui1:["Second"]Code: Select all
Module: _QuickTest_
Panel: C:\\WinCC_OA_Proj\\testing\\panels\\test.pnl []
Object: 1 named: "PUSH_BUTTON2" of type: PUSH_BUTTON
Script: Clicked
Line: 14, Given datatype does not match with needed type 'First'
WCCOAui1:["First"]