aiekick/ImGuiFileDialog

Only the first thumbnail is rendered

tloockx-aim opened this issue · 3 comments

Thanks for creating such an incredible library!

I'm having issues displaying thumbnails. In my case, only the first thumbnail is ever displayed:
image

What I think is happening is that the thread running via m_ThreadThumbnailFileDatasExtractionFunc is not waking up anymore after the first time (code link):

    while (m_IsWorking) {
        std::unique_lock<std::mutex> thumbnailFileDatasToGetLock(m_ThumbnailFileDatasToGetMutex);
        // We wait here forever.
        m_ThumbnailFileDatasToGetCv.wait(thumbnailFileDatasToGetLock);
        if (!m_ThumbnailFileDatasToGet.empty()) {

The main thread puts all the required file data on the queue in one go and wakes up the thread, but this thread only processes one thumbnail before returning to sleep forever because nobody wakes it up again.

I can hack around this by having a timeout on the wait:

    while (m_IsWorking) {
        std::unique_lock<std::mutex> thumbnailFileDatasToGetLock(m_ThumbnailFileDatasToGetMutex);
        // HACK: Wake up to check for thumbnails if nobody will wake us up!
        m_ThumbnailFileDatasToGetCv.wait_for(thumbnailFileDatasToGetLock, std::chrono::milliseconds(50));
        if (!m_ThumbnailFileDatasToGet.empty()) {

But I'm pretty sure that's not how you designed it to work.

hello,

thanks for the feedback.

btw i have no issue on my side.

can you try the DemoApp, then do that :

ImGuiFileDialog_App_Win32_XdzAAE9mhz

Okay, I verified it on the example application, and it works correct. Then it's time to go and debug my own code. Apologies, and thanks for the help!

image

np, its always interesting.

dont hesitate to let me know what was the issue (Thread Concurrency or File loading issue or what else !?), maybe if i can make something easier on my side.