From 2e839cf72bb283ada4f6e8c271fa87cbc44a68c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Sun, 25 Nov 2018 00:03:03 +0100 Subject: [PATCH] fix regressions introduced in last commit --- ChangeLog | 3 ++- fm/src/mainwindow.cpp | 15 ++++++++++++++- fm/src/mainwindow.h | 3 +++ fm/src/mymodel.cpp | 20 ++++++++------------ fm/src/mymodel.h | 5 +---- 5 files changed, 28 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 42b2a67..5189b65 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,11 @@ -6.1.4 23-November 2018 +6.1.4 26-November 2018 - fix potential config corruption. Thanks to @slackuser0xae34 for the patch - fix segfault on thumbnail update (view may have changed since loading thumbnails) - don't cut file(s) if moving to same directory in bookmarks - verify reply from udisks (avoid crash) - populate view if not watched - fix refresh view +- improved performance 6.1.3 07-October 2018 - update grid on paste/remove diff --git a/fm/src/mainwindow.cpp b/fm/src/mainwindow.cpp index 65bc2df..657e963 100644 --- a/fm/src/mainwindow.cpp +++ b/fm/src/mainwindow.cpp @@ -243,6 +243,7 @@ MainWindow::MainWindow() show(); trashDir = Common::trashDir(); + ignoreReload = false; QTimer::singleShot(0, this, SLOT(lateStart())); } @@ -716,9 +717,15 @@ void MainWindow::updateDir() void MainWindow::handleReloadDir(const QString &path) { + if (ignoreReload) { + qDebug() << "ignore reload"; + return; + } + ignoreReload = true; qDebug() << "handle reload dir" << path << modelList->getRootPath(); if (path != modelList->getRootPath()) { return; } dirLoaded(); + QTimer::singleShot(500, this, SLOT(enableReload())); } void MainWindow::thumbUpdate(const QString &path) @@ -1549,7 +1556,7 @@ void MainWindow::refresh(bool modelRefresh, bool loadDir) qDebug() << "refresh"; if (modelRefresh) { modelList->refreshItems(); - modelList->update(); + modelList->forceRefresh(); } QModelIndex baseIndex = modelView->mapFromSource(modelList->index(pathEdit->currentText())); if (currentView == 2) { detailTree->setRootIndex(baseIndex); } @@ -1559,6 +1566,12 @@ void MainWindow::refresh(bool modelRefresh, bool loadDir) dirLoaded(); } } + +void MainWindow::enableReload() +{ + qDebug() << "enable reload"; + ignoreReload = false; +} //--------------------------------------------------------------------------- /** diff --git a/fm/src/mainwindow.h b/fm/src/mainwindow.h index 3b06c95..dd57354 100644 --- a/fm/src/mainwindow.h +++ b/fm/src/mainwindow.h @@ -315,6 +315,7 @@ private slots: void handlePathRequested(QString path); void slowPathEdit(); void refresh(bool modelRefresh = true, bool loadDir = true); + void enableReload(); private: void createActions(); void createActionIcons(); @@ -453,6 +454,8 @@ private slots: QString copyXof; // custom timestamp for copy of QString copyXofTS; + + bool ignoreReload; }; //--------------------------------------------------------------------------------- diff --git a/fm/src/mymodel.cpp b/fm/src/mymodel.cpp index 555a961..1066958 100644 --- a/fm/src/mymodel.cpp +++ b/fm/src/mymodel.cpp @@ -45,7 +45,6 @@ myModel::myModel(bool realMime, MimeUtils *mimeUtils) { thumbs = new QHash; icons = new QCache; icons->setMaxCost(500); - lockNotify = false; // Loads cached mime icons QFile fileIcons(QString("%1/file.cache").arg(Common::configDir())); @@ -109,6 +108,13 @@ void myModel::clearIconCache() { QFile(QString("%1/folder.cache").arg(Common::configDir())).remove(); QFile(QString("%1/file.cache").arg(Common::configDir())).remove(); } + +void myModel::forceRefresh() +{ + qDebug() << "force refresh model view"; + beginResetModel(); + endResetModel(); +} //--------------------------------------------------------------------------- /** @@ -287,11 +293,6 @@ void myModel::eventTimeout() void myModel::notifyProcess(int eventID, QString fileName) { qDebug() << "notifyProcess" << eventID << fileName; - if (lockNotify) { - qDebug() << "ignore notify"; - return; - } - lockNotify = true; QString folderChanged; if (watchers.contains(eventID)) { myModelItem *parent = rootItem->matchPath(watchers.value(eventID).split(SEPARATOR)); @@ -333,7 +334,6 @@ void myModel::notifyProcess(int eventID, QString fileName) qDebug() << "folder modified" << folderChanged; emit reloadDir(folderChanged); } - QTimer::singleShot(500, this, SLOT(unlockNotify())); } //--------------------------------------------------------------------------------- @@ -454,6 +454,7 @@ void myModel::refreshItems() { myModelItem *item = rootItem->matchPath(currentRootPath.split(SEPARATOR)); if (item == NULL) { return; } + qDebug() << "refresh items"; item->clearAll(); populateItem(item); } @@ -927,11 +928,6 @@ QVariant myModel::findMimeIcon(myModelItem *item) const { return theIcon; } -void myModel::unlockNotify() -{ - qDebug() << "unlock notify"; - lockNotify = false; -} //--------------------------------------------------------------------------- bool myModel::setData(const QModelIndex & index, const QVariant & value, int role) diff --git a/fm/src/mymodel.h b/fm/src/mymodel.h index 6c01369..4b368b9 100644 --- a/fm/src/mymodel.h +++ b/fm/src/mymodel.h @@ -86,6 +86,7 @@ public slots: void addWatcher(myModelItem* path); void clearCutItems(); void clearIconCache(); + void forceRefresh(); signals: void dragDropPaste(const QMimeData *data, QString newPath, Common::DragMode mode = Common::DM_UNKNOWN); @@ -104,7 +105,6 @@ public slots: bool realMimeTypes; bool showThumbs; int thumbCount; - bool lockNotify; QPalette colors; QStringList cutItems; @@ -123,9 +123,6 @@ public slots: QTimer eventTimer; int lastEventID; QString lastEventFilename; - -private slots: - void unlockNotify(); }; #endif // MYMODEL_H