This works:
for (unsigned int i = 0; i < 30; ++i)
{
EditBoxNames[i] = Group1->get("Ime" + tgui::to_string(i)); // call EditBox named Ime
GroupNames.push_back(EditBoxNames[i]->getText()); // Take values from
saveGroup1Names(GroupNames); // call function to save Names to file
EditBoxLastNames[i] = Group1->get("Prezime" + tgui::to_string(i));
GroupLastNames.push_back(EditBoxLastNames[i]->getText());
saveGroup1LastNames(GroupLastNames);
EditBoxBrojTelefona[i] = Group1->get("BrojTelefona" + tgui::to_string(i));
GroupBrojTelefona.push_back(EditBoxBrojTelefona[i]->getText());
saveGroup1BrojTelefona(GroupBrojTelefona);
EditBoxDatumRodjenja[i] = Group1->get("DatumRodjenja" + tgui::to_string(i));
GroupDatumRodjenja.push_back(EditBoxDatumRodjenja[i]->getText());
saveGroup1DatumRodjenja(GroupDatumRodjenja);
TextBoxGrupaNapomene[i] = Group1Napomene->get("Group1NapomeneUcenik" + tgui::to_string(i));
GroupNapomene.push_back(TextBoxGrupaNapomene[i]->getText());
saveGroup1Napomene(GroupNapomene);
}
After that i called:
// here was for loop from prevoius code
// here was cout about vector size and capacity [ see picture ]
EditBoxNames.clear();
EditBoxLastNames.clear();
EditBoxBrojTelefona.clear();
EditBoxDatumRodjenja.clear();
// here was cout about new size and capacity [see picture ]
// new for loop starts here
So i clear those vectors to use them again in new for loop [ if needed i will post new for loop ] . And just before new for loop program crashes with core dumped. dbg says:
-------------------------------------------------------------------
nr: Adress: Func: File:
#0 0xb7d587b8 ??() (/lib/i386-linux-gnu/libc.so.6:??)
#1 ?? ?? () (??:??)
--------------------------------------------------------------------
picture: http://s16.postimg.org/ro920dvd1/Screenshot_from_2013_07_25_16_18_44.png .
Have i done vectorName.clear wrong? Or it is something else?
Using gcc 4.6.3
code blocks 12.11
elementary os Luna Beta 2
if need more details ask and i will post
thank you in advance
wmbuRn
EDIT: When i comment entire new for loop with /* */ program doesnt crash. And it does do whatever is suposed to do. New for loop uses same vectors just like for loop i posted
This is how they are declared as global variables.
std::vector<sf::String> GroupNames;
std::vector<tgui::EditBox::Ptr> EditBoxNames;
std::vector<sf::String> GroupLastNames;
std::vector<tgui::EditBox::Ptr> EditBoxLastNames;
std::vector<sf::String> GroupBrojTelefona;
std::vector<tgui::EditBox::Ptr> EditBoxBrojTelefona;
std::vector<sf::String> GroupDatumRodjenja;
std::vector<tgui::EditBox::Ptr> EditBoxDatumRodjenja;
std::vector<sf::String> GroupNapomene;
std::vector<tgui::TextBox::Ptr> TextBoxGrupaNapomene;
for (unsigned int i = 0; i < 30; ++i)
{
EditBoxNames[i] = Group2->get("Ime" + tgui::to_string(i));
GroupNames.push_back(EditBoxNames[i]->getText());
saveGroup2Names(GroupNames);
EditBoxLastNames[i] = Group2->get("Prezime" + tgui::to_string(i));
GroupLastNames.push_back(EditBoxLastNames[i]->getText());
saveGroup2LastNames(GroupLastNames);
EditBoxBrojTelefona[i] = Group2->get("BrojTelefona" + tgui::to_string(i));
GroupBrojTelefona.push_back(EditBoxBrojTelefona[i]->getText());
saveGroup2BrojTelefona(GroupBrojTelefona);
EditBoxDatumRodjenja[i] = Group2->get("DatumRodjenja" + tgui::to_string(i));
GroupDatumRodjenja.push_back(EditBoxDatumRodjenja[i]->getText());
saveGroup2DatumRodjenja(GroupDatumRodjenja);
TextBoxGrupaNapomene[i] = Group2Napomene->get("Group2NapomeneUcenik" + tgui::to_string(i));
GroupNapomene.push_back(TextBoxGrupaNapomene[i]->getText());
saveGroup2Napomene(GroupNapomene);
}
It is almost the same loop as before. Except this loop calls Group2 instead Group1
EDIT: Give me a second to test code again i havent erased all of the vectors. :)
I cleared all the vector i am using [10 of them)
EditBoxNames.clear();
EditBoxLastNames.clear();
EditBoxBrojTelefona.clear();
EditBoxDatumRodjenja.clear();
TextBoxGrupaNapomene.clear();
GroupNames.clear();
GroupLastNames.clear();
GroupDatumRodjenja.clear();
GroupBrojTelefona.clear();
GroupNapomene.clear();
Same error happends