Sideconditions in QDir-constructor?

(I´ve got a file with an URL in each line. I want to get the URL given in the oid-th line. For my current problem, just the first 5 lines are important.)
@
QUrl MyClass::getUrl(int oid) {
QString tmp = MyConstants::filelocation();
qdebug() << "1" << tmp;
QDir tmpDir(tmp); //here, it crashes
qdebug() << "2";
QFile* f = new QFile(tmpDir.absoluteFilePath("Objects2.dat"));
QString resultByteArray;
if (f->exists()) {
f->open(QIODevice::ReadOnly); //TODO: catch false
for (int i = 0; i < oid; i++) {
if (f->atEnd()) {
qwarning() << tmpDir.absoluteFilePath("objects.dat") << " has less than " << oid << " entries.";
return QUrl(".");
}
f->readLine();
}
resultByteArray = f->readLine();
resultByteArray.remove(QRegExp("\r"));
resultByteArray.remove(QRegExp("\n"));
f->close();
} else {
qwarning() << "Failed to open " << tmpDir.absoluteFilePath("Objects2.dat") << ".";
}
delete f;
QString result = resultByteArray;
return QUrl(result);
}
@
I call this function twice in my program. In one case, it always works and in a second, it always crashes, when I call the constructor of QDir.
Are there any sideconditions, which must be fullfilled, so that I can call the constructor successfully?
By the way: tmp (my filelocation) is the same in both situations...

There are no special conditions to be fulfilled. You might be experiencing a memory corruption or something like that. These can pop up their ugly heads at seemingly totally unrelated pieces of code. Try using valgrind or something like that to check for these.