Details
-
Bug
-
Resolution: Incomplete
-
P3: Somewhat important
-
None
-
5.0.2
-
None
-
clang3.2, mac 10.8.3, Qt5.0.2
Description
Sometimes this would crash(race condition?) if you don’t lock the save function
Is this a bug? Or a behavior of save?In Qt4 I haven’t found this kind of problem yet
These are part of the error messages after the .app crash
http://www.flickr.com/photos/92283971@N04/8678167798/in/photostream
ps : there are the other small bug, the SLOT aboutQt will always show you you are using Qt5.0.1 but not Qt5.0.2
#include <functional>
#include <QApplication>
#include <QtConcurrent/QtConcurrentMap>
#include <QImage>
#include <QLabel>
//QMutex mutex;
int process_image_impl(QString const &name)
{
QImage image(name);
if(!image.isNull())
{ //QMutexLocker(&QMutex); you have to lock it to prevent undefined behavior image.save("save/" + name); } return 0;
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
namespace ph = std::placeholders;
QStringList image_name;
for(size_t i = 0; i != 10; ++i)
QtConcurrent::blockingMapped(image_name, std::bind<int>(process_image_impl, ph::_1));
QLabel w;
w.show();
return a.exec();
}
The images are compress in the zip file