From 46fd4f4d4e41f4d9b89c1549c6bc678d74476687 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 14 Oct 2015 14:47:33 -0400 Subject: Fix a crash in the thumbnail loading routine where an invalid item can accidentally get passed through to the loading mechanisms (usually after a drop event or other file operations). --- lumina-fm/widgets/DirWidget.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'lumina-fm/widgets/DirWidget.cpp') diff --git a/lumina-fm/widgets/DirWidget.cpp b/lumina-fm/widgets/DirWidget.cpp index 2cef549f..a4096370 100644 --- a/lumina-fm/widgets/DirWidget.cpp +++ b/lumina-fm/widgets/DirWidget.cpp @@ -22,9 +22,7 @@ #include "../ScrollDialog.h" -#ifndef DEBUG -#define DEBUG 1 -#endif +#define DEBUG 0 const QString sessionsettings_config_file = QDir::homePath() + "/.lumina/LuminaDE/sessionsettings.conf"; @@ -190,8 +188,8 @@ void DirWidget::LoadDir(QString dir, QList list){ QString lastdir = CDIR; //for some checks later QString lastbasedir = normalbasedir; CDIR = dir; - if(CDIR.endsWith("/") && CDIR.length() != 1){ CDIR.chop(1); } - CLIST = list; //save for laterr + if(CDIR.endsWith("/") && CDIR.length() > 1){ CDIR.chop(1); } + CLIST = list; //save for later canmodify = QFileInfo(CDIR).isWritable(); if(DEBUG){ qDebug() << "Clear UI:" <findItems(needThumbs[i], Qt::MatchExactly).first(); + QList items = treeWidget->findItems(needThumbs[i], Qt::MatchExactly); + if(items.isEmpty()){ continue; } //invalid item for some reason + QTreeWidgetItem *it = items.first(); it->setIcon(0, QIcon( QPixmap(it->whatsThis(0).section("::::",1,100)).scaled(listWidget->iconSize(),Qt::IgnoreAspectRatio, Qt::FastTransformation) ) ); }else{ //Use the list widget - QListWidgetItem *it = listWidget->findItems(needThumbs[i], Qt::MatchExactly).first(); + QList items = listWidget->findItems(needThumbs[i], Qt::MatchExactly); + if(items.isEmpty()){ continue; } + QListWidgetItem *it = items.first(); it->setIcon(QIcon( QPixmap(it->whatsThis().section("::::",1,100)).scaled(listWidget->iconSize(),Qt::IgnoreAspectRatio, Qt::FastTransformation) ) ); } if(QTime::currentTime() > updatetime){ QApplication::processEvents(); updatetime = QTime::currentTime().addMSecs(500); }//keep the UI snappy while loading a directory @@ -950,10 +953,10 @@ void DirWidget::startSync(const QString &file){ //Update date_format based on user settings if(file == sessionsettings_config_file){ setDateFormat(); } else if(file == snapbasedir){ emit findSnaps(ID, normalbasedir); } //snapshot list changed - /*else if(file == normalbasedir){ - if(synctimer->isActive()){ synctimer->stop(); } //already starting a sync - emit LoadDirectory(ID, normalbasedir); //Directory changed (new/removed files) - }*/else{ + else if(file == normalbasedir){ + if(synctimer->isActive()){ synctimer->stop(); } //already starting a sync - restart the timer + synctimer->start(); + }else{ //Some file in the directory got changed - start the time for a dir reload // -- This prevents a directory from refreshing constantly if a file within the directory is changing all the time (such as a log file) if(!synctimer->isActive()){ synctimer->start(); } -- cgit