Question

I am building up a QListWidget, browsing through a directory so that every ".png" gets listed with a preview icon.

The core of my populating loop looks like this:

new QListWidgetItem( QIcon(act_fullname), act_filename);

Right after the whole list is ready, the app crashes. The error is many times repeated and says this:

On Mac OS X, you might be loading two sets of Qt binaries into the same process. Check that all plugins are compiled against the right Qt binaries. Export DYLD_PRINT_LIBRARIES=1 and check that only one set of binaries are being loaded. QObject::moveToThread: Current thread (0x103339cb0) is not the object's thread (0x10a848670). Cannot move to target thread (0x103339cb0)

On Mac OS X, you might be loading two sets of Qt binaries into the same process. Check that all plugins are compiled against the right Qt binaries. Export DYLD_PRINT_LIBRARIES=1 and check that only one set of binaries are being loaded.

Do you have any ideas?

Thanks for your help!

EDIT:

If I skip the icons there is no problem. I have also tried going

QListWidgetItem *item = new QListWidgetItem(act_filename);
ui->listWidget->addItem(item);
item->setIcon(QIcon(act_fullname));

and got no difference.

EDIT 2:

I do not call QObject::moveToThread(QThread*) I don't even use threads (deliberately at least).

Also, the errors appear to come after the loop. I have cout-ed every iteration and the end of the loop and right after my "end loop cout msg" I see that

objc[56963]: Class QCocoaColorPanelDelegate is implemented in both /Users/Barnabas/QtSDK/Desktop/Qt/4.8.1/gcc/lib/QtGui.framework/Versions/4/QtGui and /Users/Barnabas/Programming/Qt/demo_OpenCV-build-desktop-Desktop_Qt_4_8_1_for_GCC__Qt_SDK__Release/demo_OpenCV.app/Contents/MacOS/../Frameworks/QtGui.framework/Versions/4/QtGui. One of the two will be used. Which one is undefined.

Here, too, I do not use QCocoaColorPanelDelegate. I don't even know what it is ... :(

But here is my more detailed code:

boost::filesystem::path p("/path/to/dir");
if(boost::filesystem::is_directory(p))
{
    for(boost::filesystem::directory_iterator it(p); it!=boost::filesystem::directory_iterator(); ++it)
    {
        if(it->path().extension().string()==".png")
        {
            std::cout<< it->path() <<std::endl;
            QString item_name( it->path.stem().c_str() );
            QString screen_file( it->path.c_str() );
            QListWidgetItem *item = new QListWidgetItem(item_name);
            QIcon *icon = new QIcon(screen_file);
            item->setIcon(*icon); // if I comment this one out, everything is fine.
            ui->imageList->addItem(item);
        }
    }
}

I have also tested it with a single .png and the image was displayed properly in the list but crash followed with the very same messages.

Was it helpful?

Solution

I have finally found the solution: manually removed the Debug and the Release directories.
For those whose similar problem is not solved by this see: this link.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top