Expression: vector iterator not incrementable

Hi.

Please, I came from processing quite recently to OF.
Need some help debugging a mac working project to a windows compilation:

This code adds menu names from vector selected2. It´s working fine on xCode but VisualStudio says
vector iterator not incrementable when at mouseReleased from the ofxUI function.

string name2 = e.widget->getName();
ofxUIToggle *toggle2 = (ofxUIToggle *)e.widget;
ddl2->setShowCurrentSelected(toggle2->getValue());

if (name2 == "Ramos de Atividade")
{
	ofxUIDropDownList *ddlist2 = (ofxUIDropDownList *)e.widget;
	vector<ofxUIWidget *> &selected2 = ddlist2->getSelected();

	for (int i = 0; i < selected2.size(); i++)
	{
		nameToMenu = selected2[i]->getName();
	}
	

	if (g_img_N == 1 && g_changeMenu == true) {

		ddl2->clearToggles();

		string add= "";
		std::set<std::string>::iterator it_names = RArtLar.v_setRamos.begin();

		for (int i = 0; i< RArtLar.maxElements; i++) {

			add+= *it_names;
			ddl2->addToggle(*it_names);
			// cout << "*it_names : " << *it_names << endl;
			add+= "\n";
			it_names++;

		}
		g_changeMenu = false;
	}

Mouse release is what activates that code from the ofxUI addon:

void ofxUICanvas::mouseReleased(int x, int y, int button)
{
vector<ofxUIWidget *>::iterator it = widgets.begin();
vector<ofxUIWidget *>::iterator eit = widgets.end();
for(; it != eit; ++it) // ---- HERE GOES THE ITERATOR NOT INCRMENTABLE
{
if((*it)->isVisible())
{
(*it)->mouseReleased(x, y, button);
}
}
}

not sure what’s the problem since the code looks correct but it’s much easier to do:

for(auto & widget: widgets){
    if(widget->isVisible()){
        widget->mouseReleased(x,y,button);
    }
}
1 Like

Thank you for the quick reply arturo.
You have indeed perfected the ofxUI lib code :)’

I supposed that problem have to do with the way macOS frameworks works differently from windows on string vectors, is that possible? If iterator value is 0 before I make the the first choice on the dropdown menu1, then there are no values on menu2 ( string name2 ), so being not incrementable? (Only for windows)

sorry for raising this issue :slight_smile:

this cycle gets its incrementation from a vector that have an issue at its class:
[! implicit conversion loses integer precision: <size_type> (aka’unsigned long’) to ‘int’ ]

do anyone have ideia if it could this be related to the problem ?