aboutsummaryrefslogtreecommitdiff
path: root/src-qt5
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2018-02-09 15:08:20 -0500
committerKen Moore <ken@ixsystems.com>2018-02-09 15:08:20 -0500
commit6f893d72686b0153c23385c28666c3ada68e1f5d (patch)
tree2fa6ae0d6ea2a60e96765882b96b4f3954a9cb7f /src-qt5
parentBump the minor version of Lumina to 1.4.2 (diff)
downloadlumina-6f893d72686b0153c23385c28666c3ada68e1f5d.tar.gz
lumina-6f893d72686b0153c23385c28666c3ada68e1f5d.tar.bz2
lumina-6f893d72686b0153c23385c28666c3ada68e1f5d.zip
Fix up a number of crashes related to item loading times and multiple columns
Diffstat (limited to 'src-qt5')
-rw-r--r--src-qt5/desktop-utils/lumina-fm/Browser.cpp35
-rw-r--r--src-qt5/desktop-utils/lumina-fm/Browser.h4
-rw-r--r--src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp10
-rw-r--r--src-qt5/desktop-utils/lumina-fm/BrowserWidget.h1
-rw-r--r--src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp4
5 files changed, 47 insertions, 7 deletions
diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.cpp b/src-qt5/desktop-utils/lumina-fm/Browser.cpp
index 50099a51..dfe402e1 100644
--- a/src-qt5/desktop-utils/lumina-fm/Browser.cpp
+++ b/src-qt5/desktop-utils/lumina-fm/Browser.cpp
@@ -17,6 +17,11 @@ Browser::Browser(QObject *parent) : QObject(parent){
watcher = new QFileSystemWatcher(this);
connect(watcher, SIGNAL(fileChanged(const QString&)), this, SLOT(fileChanged(QString)) );
connect(watcher, SIGNAL(directoryChanged(const QString&)), this, SLOT(dirChanged(QString)) );
+ updateTimer = new QTimer(this);
+ updateTimer->setInterval(500);
+ updateTimer->setSingleShot(true);
+ connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateRequested()) );
+
showHidden = false;
showThumbs = false;
imageFormats = LUtils::imageExtensions(false); //lowercase suffixes
@@ -84,8 +89,12 @@ QIcon* Browser::loadIcon(QString icon){
void Browser::fileChanged(QString file){
//qDebug() << "Got File Changed:" << file;
if(file.section("/",0,-2) == currentDir){
- if(QFile::exists(file) ){ QtConcurrent::run(this, &Browser::loadItem, file, this); } //file modified but not removed
- else if(oldFiles.contains(file) ){
+ if(QFile::exists(file) ){
+ updateList << file;
+ if(!updateTimer->isActive()){ updateTimer->start(); }
+ //QtConcurrent::run(this, &Browser::loadItem, file, this); //file modified but not removed
+
+ }else if(oldFiles.contains(file) ){
oldFiles.removeAll(file);
emit itemRemoved(file);
}
@@ -94,8 +103,10 @@ void Browser::fileChanged(QString file){
void Browser::dirChanged(QString dir){
//qDebug() << "Got Dir Changed:" << dir;
- if(dir==currentDir){ QTimer::singleShot(10, this, SLOT(loadDirectory()) ); }
- else if(dir.startsWith(currentDir)){ QtConcurrent::run(this, &Browser::loadItem, dir, this ); }
+ updateList << dir;
+ if(!updateTimer->isActive()){ updateTimer->start(); }
+ //if(dir==currentDir){ QTimer::singleShot(10, this, SLOT(loadDirectory()) ); }
+ //else if(dir.startsWith(currentDir)){ QtConcurrent::run(this, &Browser::loadItem, dir, this ); }
}
void Browser::futureFinished(QString name, QImage icon){
@@ -125,11 +136,27 @@ void Browser::futureFinished(QString name, QImage icon){
//qDebug() << " -- done:" << name;
}
+void Browser::updateRequested(){
+ //Clear the cache list ASAP
+ QStringList list = updateList;
+ updateList.clear();
+ list.removeDuplicates();
+ //Now look to see if an all-dir update is needed
+ if(list.contains(currentDir)){ QTimer::singleShot(10, this, SLOT(loadDirectory()) ); }
+ else{
+ //individual file updates
+ for(int i=0; i<list.length(); i++){
+ if(QFile::exists(list[i])){ QtConcurrent::run(this, &Browser::loadItem, list[i], this); }
+ }
+ }
+}
+
// PUBLIC SLOTS
void Browser::loadDirectory(QString dir, bool force){
if(force){ lastcheck = QDateTime(); } //reset check time to force reloads
if(dir.isEmpty()){ dir = currentDir; } //reload current directory
if(dir.isEmpty()){ return; } //nothing to do - nothing previously loaded
+ updateList.clear();
//qDebug() << "Load Directory" << dir;
bool dirupdate = true;
if(currentDir != dir){ //let the main widget know to clear all current items (completely different dir)
diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.h b/src-qt5/desktop-utils/lumina-fm/Browser.h
index 0ad27fdb..c6a15218 100644
--- a/src-qt5/desktop-utils/lumina-fm/Browser.h
+++ b/src-qt5/desktop-utils/lumina-fm/Browser.h
@@ -40,8 +40,9 @@ private:
QFileSystemWatcher *watcher;
QMap<QString, QPixmap> videoImages;
bool showHidden, showThumbs;
- QStringList imageFormats, videoFormats, oldFiles;
+ QStringList imageFormats, videoFormats, oldFiles, updateList;
QHash<QString, QIcon> mimeIcons; //cache for quickly re-using QIcons
+ QTimer *updateTimer;
void loadItem(QString info, Browser *obj); //this is the main loader class - multiple instances each run in a separate thread
QIcon* loadIcon(QString icon); //simplification for using/populating the mimIcons cache
@@ -50,6 +51,7 @@ private slots:
void fileChanged(QString); //tied into the watcher - for file change notifications
void dirChanged(QString); // tied into the watcher - for new/removed files in the current dir
void futureFinished(QString, QImage);
+ void updateRequested();
public slots:
void loadDirectory(QString dir = "", bool force = false);
diff --git a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp
index 5a08b797..82ce8a33 100644
--- a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp
+++ b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp
@@ -39,11 +39,17 @@ BrowserWidget::BrowserWidget(QString objID, QWidget *parent) : QWidget(parent){
}
BrowserWidget::~BrowserWidget(){
+ if(bThread->isRunning()){ bThread->exit(); }
BROWSER->deleteLater();
- bThread->exit();
bThread->deleteLater();
}
+void BrowserWidget::stop(){
+ bThread->exit();
+ this->setVisible(false);
+ this->disconnect();
+}
+
void BrowserWidget::changeDirectory(QString dir){
if(USE_VIDEO_LABEL){
QStringList vids = videoMap.keys();
@@ -305,8 +311,10 @@ void BrowserWidget::itemRemoved(QString item){
}
void BrowserWidget::itemDataAvailable(QIcon ico, LFileInfo *info){
+ if(info==0){ return; }
if(listWidget!=0){ listWidget->setWhatsThis( BROWSER->currentDirectory() ); }
if(treeWidget!=0){ treeWidget->setWhatsThis(BROWSER->currentDirectory() ); }
+ if(info->absolutePath() != BROWSER->currentDirectory()){ return; } //leftover item from a previous load
//qDebug() << "Item Data Available:" << info->fileName();
int num = 0;
if(listWidget!=0){
diff --git a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h
index 2f8c3ed7..dc7c95c1 100644
--- a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h
+++ b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h
@@ -40,6 +40,7 @@ public:
~BrowserWidget();
QString id(){ return ID; }
+ void stop();
void changeDirectory(QString dir);
QString currentDirectory(){ return BROWSER->currentDirectory(); }
diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp
index d3b0ae2b..ce5dfd81 100644
--- a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp
+++ b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp
@@ -473,9 +473,11 @@ void DirWidget::on_actionSingleColumn_triggered(bool checked){
if(!checked){ return; }
if(RCBW==0){ return; } //nothing to do
ui->browser_layout->removeWidget(RCBW);
- RCBW->deleteLater();
+ RCBW->stop();
+ BrowserWidget *tmp = RCBW;
RCBW = 0;
setCurrentBrowser(""); //reset back to the remaining browser
+ QTimer::singleShot(10000, tmp, SLOT(deleteLater()));
}
void DirWidget::on_actionDualColumn_triggered(bool checked){
bgstack15