i've got a problem, and i think its caused by a wxThread class of mine.
I've got a normal wxFrame class, which starts a second class in a seprated wxThread.
Code: Select all
wxThread::ExitCode MyBarcodeReader::Entry()
{
char* receivedString = NULL;
size_t readedBytes = 0;
//Warte auf den ersten string
int state = comDevice->ReadUntilEOS(receivedString,&readedBytes,"\r",timeout);
if(readedBytes > 0) {
receivedString[readedBytes] = 0;
((MyFrame*)frame)->addArtikel(receivedString);
}
//Solange kein Timeout passiert, weiter abfragen
while(state == 1) {
state = comDevice->ReadUntilEOS(receivedString,&readedBytes,"\r");
if(readedBytes > 0) {
receivedString[readedBytes] = 0;
((MyFrame*)frame)->addArtikel(receivedString);
}
}
//Port wieder schließen
comDevice->Close();
//Scanner Status ändern
((MyFrame*)frame)->setScannerState(false);
return 0;
}
If it does, the class calls a method in my Frame class to add it to a wxGrid ( the barcode ). This happens in addArtikel:
Code: Select all
void MyFrame::addArtikel(std::string artikel)
{
//String aufspalten
std::string sn = artikel.substr(0,artikel.find("|"));
std::string kn = artikel.substr(artikel.find("|")+1,artikel.size());
//Neues Tab erstellen, Grid anlegen und Daten einfügen
std::map<std::string,wxGrid*>::iterator it = kundendaten.insert(std::make_pair(kn,new wxGrid(notebook, wxID_ANY))).first;
it->second->CreateGrid(0,1,wxGrid::wxGridSelectRows);
it->second->SetColLabelValue(0,"Artikel");
it->second->SetColSize(0,200);
it->second->AppendRows(1);
it->second->SetCellValue(it->second->GetNumberRows()-1,0,sn);
notebook->AddPage(it->second, kn, true, 0);
}
The page is added but the wxGrid doesnt show up. For about a second there are some grey fields and then they disapear and there is only the tab of the notebook ctrl is left.
Could this be a Thread problem, because if i create the tab and the wxGrid in another method of my wxFrame class, it works.
Thanks for help