Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QImage crash when saving image(Qt5.0.2) on mac osx 10.8.3



  • Codes

    @#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){
        image_name <<("onebit_" + QString::number(30 + i) + ".png");
    }
    QtConcurrent::blockingMapped(image_name, std::bind<int>(process_image_impl, ph::_1));
    
    QLabel w;
    w.show();
    
    return a.exec(&#41;;
    

    }@

    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

    Sorry, I don't know how to trace the bugs by callstack on mac yet
    It wouldn't generate the callstack trace like this page show

    "callstack":http://doc.qt.digia.com/qtcreator/creator-debug-mode.html

    These are part of the error messages after the .app crash
    Anyone know how to decipher the messages?
    Could I find out the program crash on which line by the messages?
    Or I have an easier way to map the address to source codes?

    "error messages":http://www.flickr.com/photos/92283971@N04/8678167798/in/photostream

    Should I treat this as a bug and report?

    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


Log in to reply