mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-28 10:40:39 +00:00
Qt: fix crash on switching playlists quickly
This commit is contained in:
parent
a082ea7d76
commit
8e7e530747
@ -128,6 +128,7 @@ GridItem::GridItem() :
|
||||
,image()
|
||||
,pixmap()
|
||||
,imageWatcher()
|
||||
,mutex()
|
||||
{
|
||||
}
|
||||
|
||||
@ -738,8 +739,12 @@ MainWindow::~MainWindow()
|
||||
|
||||
void MainWindow::onZoomValueChanged(int value)
|
||||
{
|
||||
if (m_gridItems.count() == 0)
|
||||
return;
|
||||
|
||||
foreach(GridItem *item, m_gridItems)
|
||||
{
|
||||
QMutexLocker lock(&item->mutex);
|
||||
int newSize = 0;
|
||||
|
||||
if (value < 50)
|
||||
@ -2816,11 +2821,16 @@ void MainWindow::removeGridItems()
|
||||
|
||||
if (item)
|
||||
{
|
||||
item->mutex.lock();
|
||||
|
||||
items.remove();
|
||||
|
||||
m_gridLayout->removeWidget(item->widget);
|
||||
|
||||
delete item->widget;
|
||||
|
||||
item->mutex.unlock();
|
||||
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
@ -2830,13 +2840,25 @@ void MainWindow::removeGridItems()
|
||||
void MainWindow::onDeferredImageLoaded()
|
||||
{
|
||||
const QFutureWatcher<GridItem*> *watcher = static_cast<QFutureWatcher<GridItem*>*>(sender());
|
||||
GridItem *item = watcher->result();
|
||||
GridItem *item = NULL;
|
||||
|
||||
if (!watcher)
|
||||
return;
|
||||
|
||||
item = watcher->result();
|
||||
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
item->mutex.lock();
|
||||
|
||||
if (!item->image.isNull())
|
||||
{
|
||||
item->label->setPixmap(QPixmap::fromImage(item->image));
|
||||
item->label->update();
|
||||
}
|
||||
|
||||
item->mutex.unlock();
|
||||
}
|
||||
|
||||
void MainWindow::loadImageDeferred(GridItem *item, QString path)
|
||||
@ -2848,8 +2870,15 @@ void MainWindow::loadImageDeferred(GridItem *item, QString path)
|
||||
GridItem* MainWindow::doDeferredImageLoad(GridItem *item, QString path)
|
||||
{
|
||||
/* this runs in another thread */
|
||||
if (!item)
|
||||
return NULL;
|
||||
|
||||
item->mutex.lock();
|
||||
|
||||
item->image = QImage(path);
|
||||
|
||||
item->mutex.unlock();
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
@ -75,6 +75,7 @@ struct GridItem
|
||||
QImage image;
|
||||
QPixmap pixmap;
|
||||
QFutureWatcher<GridItem*> imageWatcher;
|
||||
QMutex mutex;
|
||||
};
|
||||
|
||||
class ThumbnailWidget : public QWidget
|
||||
|
Loading…
Reference in New Issue
Block a user