QTemporaryFile bug
Posted: Mon Aug 31 2020 7:16 pm
If there is an official bug database please let me know and I will put this there along with the malloc crash thing I reported earlier.
From the doc, Detailed Description section
I was having no end of trouble getting a temporary file to work in my Diamond editor coding today. So, I changed my "Hello World!" program to have the following.
Build it, run it, and have the exact same problem.
I was trying to use a template name so I could keep the original file extension (i.e. .cpp). At first I thought this was just a problem with template names, but it appears QTemporaryFile doesn't work at all. Just for grins I tried a non-parented version and got the same results.
From the doc, Detailed Description section
Code: Select all
// Within a function/method
QTemporaryFile file;
if (file.open()) {
// file.fileName() returns the unique file name
}
// QTemporaryFile destructor removes the temporary file as it goes out of scope.Code: Select all
void Task::run()
{
// Do processing here
qDebug() << "Hello World!";
QTemporaryFile file(this);
if (file.open())
{
qDebug() << "temporary file name: " << file.fileName();
}
else
{
qDebug() << "failed to open temporary file";
}
emit finished();
}Code: Select all
roland@roland-amd-desktop:~/Projects/cs_hello_debug$ ./cs_hello
Hello World!
QFSFileEngine::open() No file name specified
failed to open temporary file
roland@roland-amd-desktop:~/Projects/cs_hello_debug$
Code: Select all
void Task::run()
{
// Do processing here
qDebug() << "Hello World!";
QTemporaryFile file;
if (file.open())
{
qDebug() << "temporary file name: " << file.fileName();
}
else
{
qDebug() << "failed to open temporary file";
}
emit finished();
}
Code: Select all
roland@roland-amd-desktop:~/Projects/cs_hello_debug$ ./cs_hello
Hello World!
QFSFileEngine::open() No file name specified
failed to open temporary file
roland@roland-amd-desktop:~/Projects/cs_hello_debug$