Crash trying to retrieve enum node choices

I am trying to retrieve the list of available choices for an enumeration node.

I was expecting that this could be achieved via (featurename=“PixelFormat”)

my_function(const Cvb::String &featurename, std::vector<Cvb::EnumEntryNodePtr> &list)
	
std::map<Cvb::String, Cvb::NodeMapPtr> nodemap = pDevice->NodeMaps();  
Cvb::String devicemapname                      = CVB_LIT("Device");
Cvb::NodeMapPtr devicemapptr                   = pDevice->NodeMap(devicemapname);
auto featurenode = devicemapptr->Node<Cvb::EnumerationNode>(featurename);
			
list = featurenode->Entries();		

However, the last line (“list =…”) creates a heap corruption error message, and the program crashes (as does std::cerr << featurenode->Entries().size() , so it´s not a problem with the “list” parameter).

QString featurevalue  = Cvb::CvbStringToQString(featurenode->Value());
std::string nodename_utf8 = featurevalue.toUtf8();
std::cerr << "Node value=" << nodename_utf8 << std::endl;

gives a valid output (“Mono12”); so the pointer (featurenode) is valid.
What could be going wrong here?
What do I need to do in order to use Entries() ?

Version is 13.000.005

Hi @Jakob,

unfortunately you discovered a bug in the wrapper. Your code is fine! I just fixed it in the wrappers.
Actually there are two bugs involved - both will be fixed in the next setup available tomorrow.

First bug, you are by default using Unicode strings, but this should only be enabled if you add UNICODE as preprocessor define. Currently defining UNICODE will make the opposite declaring CVB::String as a ANSI string

Second bug, Entries() did not work with UNICODE enabled.

Workaround (this won’t work once it is fixed):
In order to proceed, immediately you can define UNICODE for the preprocessor causing Cvb::String to become an ANSI string and Entries() will work - this is probably what you intended anyway.
Just keep in mind you have to remove the define as soon as you update the wrapper to stay with ANSI, otherwise you will then switch back to UNICODE.
Basically you can exploit the first bug to get rid of the second.

1 Like

The workaround seems to do the job - that´s great, for this project I currently don´t really care whether Cvb::String is char or wchar. Thanks!