PDA

View Full Version : Recursion Problem



kingfinn
23rd January 2010, 21:15
Hey there,

for some Reason this recursion never ends.
What is wrong?
Little Explanation: The Query is sent to a PHP Backend that does the SQL Query and prints the Data.

Oh, and In my Db There are only 3 entries, which all have the pId 0. But for some reason The pId 1 also gives 3 entries??


void DirParser::getSubDirs(Dir* dir) {
buffer->seek(0);
QString query = "SELECT%20*%20FROM%20dirs%20WHERE%20pId="+QString().setNum(dir->getId());
//http->post("/backend.php", ("pw="+backendPw+"&query="+query).toAscii(), buffer);
http->syncGet("/backend.php?pw="+backendPw+"&query="+query, buffer);
QMessageBox box;
box.setText(QString(buffer->data().data()));
box.exec();
QList<QByteArray> lines = buffer->data().split('\n');
foreach(QByteArray line, lines) {
QString values;
for(int i=0;i<line.size();i++)
values += line[i];
QStringList attr = values.split('\t');
if(attr.count() == 5)
dir->children.append(new Dir(dir, attr[0].toInt(), attr[2], attr[3]));
}
}

void DirParser::parseDirStructure(Dir* dir) {
getSubDirs(dir);
foreach(Dir* child, dir->children)
parseDirStructure(child);
}


JUST SOLVED IT !!!
I have to delete the buffer everytime, because, else there is the old data still in it.