Skip to content

Commit 03136e5

Browse files
authored
Merge pull request #75 from rodlie/6.1-wip
6.1.4 fixes
2 parents 4d21df6 + 2f10608 commit 03136e5

File tree

9 files changed

+46
-31
lines changed

9 files changed

+46
-31
lines changed

AUTHORS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Developers:
22

3-
* Ole-André Rodlie (5.2018
3+
* Ole-André Rodlie
44
<ole.andre.rodlie@gmail.com>
55
* Michal Rost (8.2012 - 5.2013)
66
<rost.michal@gmail.com>

ChangeLog

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
6.1.4 XX-October 2018
1+
6.1.4 23-November 2018
22
- fix potential config corruption. Thanks to @slackuser0xae34 for the patch
3+
- fix segfault on thumbnail update (view may have changed since loading thumbnails)
4+
- don't cut file(s) if moving to same directory in bookmarks
5+
- verify reply from udisks (avoid crash)
6+
- populate view if not watched
7+
- fix refresh view
38

49
6.1.3 07-October 2018
510
- update grid on paste/remove

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ make INSTALL_ROOT=/package_temp_path install
133133

134134
## Related
135135

136-
* **[powerdwarf](https://github.com/rodlie/powerdwarf)** : Desktop Independent Power Manager.
136+
* **[powerkit](https://github.com/rodlie/powerkit)** : Desktop Independent Power Manager.
137137
* **[Openbox](http://openbox.org/wiki/Main_Page)** : Openbox is a highly configurable, next generation window manager with extensive standards support.
138138
* **[tint2](https://gitlab.com/o9000/tint2)** : A lightweight panel/taskbar for Linux and BSD.
139139
* **[qterminal](https://github.com/lxqt/qterminal)** : A lightweight Qt-based terminal emulator.

fm/qtfm.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ qtfm-tray(1)
2929
.SH BUGS
3030
See https://github.com/rodlie/qtfm/issues
3131
.SH AUTHOR
32-
Ole-Andre Rodlie (ole.andre.rodlie@gmail.com)
32+
Ole-Andre Rodlie, Michal Rost, Wittfella.

fm/src/bookmarks.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,14 +230,17 @@ bool bookmarkmodel::dropMimeData(const QMimeData * data,Qt::DropAction action,in
230230
return false;
231231
}
232232
}
233+
233234
foreach(QUrl path, files) {
234235
QFileInfo file(path.toLocalFile());
235236
//drag to bookmark window, add a new bookmark
236237
if(parent.column() == -1) {
237238
if(file.isDir()) this->addBookmark(file.fileName(),file.filePath(),0,"");
238239
return false;
239240
} else {
240-
if (mode == Common::DM_MOVE) { cutList.append(file.filePath()); }
241+
if (mode == Common::DM_MOVE) {
242+
if (file.absoluteDir() != parentPath) { cutList.append(file.filePath()); }
243+
}
241244
}
242245
}
243246

fm/src/mainwindow.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,8 @@ void MainWindow::lateStart() {
378378
connect(detailTree, SIGNAL(pressed(QModelIndex)),
379379
this, SLOT(listItemPressed(QModelIndex)));
380380

381-
connect(modelList, SIGNAL(thumbUpdate(QModelIndex)),
382-
this, SLOT(thumbUpdate(QModelIndex)));
381+
connect(modelList, SIGNAL(thumbUpdate()),
382+
this, SLOT(thumbUpdate()));
383383

384384
qApp->setKeyboardInputInterval(1000);
385385

@@ -708,12 +708,9 @@ void MainWindow::dirLoaded()
708708
updateGrid();
709709
}
710710

711-
//---------------------------------------------------------------------------
712-
void MainWindow::thumbUpdate(QModelIndex index)
711+
void MainWindow::thumbUpdate()
713712
{
714-
qDebug() << "thumbUpdate";
715-
if (currentView == 2) { detailTree->update(modelView->mapFromSource(index)); }
716-
else { list->update(modelView->mapFromSource(index)); }
713+
refresh(false, false);
717714
}
718715

719716
//---------------------------------------------------------------------------
@@ -1532,15 +1529,17 @@ QMenu* MainWindow::createOpenWithMenu() {
15321529
return openMenu;
15331530
}
15341531

1535-
void MainWindow::refresh()
1532+
void MainWindow::refresh(bool modelRefresh, bool loadDir)
15361533
{
15371534
qDebug() << "refresh";
1538-
modelList->refreshItems();
1539-
modelList->update();
1535+
if (modelRefresh) {
1536+
modelList->refreshItems();
1537+
modelList->update();
1538+
}
15401539
QModelIndex baseIndex = modelView->mapFromSource(modelList->index(pathEdit->currentText()));
15411540
if (currentView == 2) { detailTree->setRootIndex(baseIndex); }
15421541
else { list->setRootIndex(baseIndex); }
1543-
dirLoaded();
1542+
if (loadDir) { dirLoaded(); }
15441543
}
15451544
//---------------------------------------------------------------------------
15461545

fm/src/mainwindow.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ public slots:
277277
void openFolderAction();
278278
void exitAction();
279279
void dirLoaded();
280-
void thumbUpdate(QModelIndex);
280+
void thumbUpdate();
281281
void addressChanged(int,int);
282282
void loadSettings(bool wState = true, bool hState = true, bool tabState = true, bool thumbState = true);
283283
void firstRunBookmarks(bool isFirstRun);
@@ -312,7 +312,7 @@ private slots:
312312
void clearCache();
313313
void handlePathRequested(QString path);
314314
void slowPathEdit();
315-
void refresh();
315+
void refresh(bool modelRefresh = true, bool loadDir = true);
316316
private:
317317
void createActions();
318318
void createActionIcons();

fm/src/mymodel.cpp

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ QModelIndex myModel::parent(const QModelIndex &index) const
177177
//---------------------------------------------------------------------------------------
178178
bool myModel::isDir(const QModelIndex &index)
179179
{
180+
if (!index.isValid()) { return false; }
180181
myModelItem *item = static_cast<myModelItem*>(index.internalPointer());
181182
if(item && item != rootItem) { return item->fileInfo().isDir(); }
182183
return false;
@@ -185,6 +186,7 @@ bool myModel::isDir(const QModelIndex &index)
185186
//---------------------------------------------------------------------------------------
186187
QFileInfo myModel::fileInfo(const QModelIndex &index)
187188
{
189+
if (!index.isValid()) { return QFileInfo(); }
188190
myModelItem *item = static_cast<myModelItem*>(index.internalPointer());
189191
if(item) { return item->fileInfo(); }
190192
return QFileInfo();
@@ -193,6 +195,7 @@ QFileInfo myModel::fileInfo(const QModelIndex &index)
193195
//---------------------------------------------------------------------------------------
194196
qint64 myModel::size(const QModelIndex &index)
195197
{
198+
if (!index.isValid()) { return 0; }
196199
myModelItem *item = static_cast<myModelItem*>(index.internalPointer());
197200
if(item) { return item->fileInfo().size(); }
198201
return 0;
@@ -201,14 +204,16 @@ qint64 myModel::size(const QModelIndex &index)
201204
//---------------------------------------------------------------------------------------
202205
QString myModel::fileName(const QModelIndex &index)
203206
{
207+
if (!index.isValid()) { return QString(); }
204208
myModelItem *item = static_cast<myModelItem*>(index.internalPointer());
205209
if(item) { return item->fileName(); }
206-
return "";
210+
return QString();
207211
}
208212

209213
//---------------------------------------------------------------------------------------
210214
QString myModel::filePath(const QModelIndex &index)
211215
{
216+
if (!index.isValid()) { return QString(); }
212217
myModelItem *item = static_cast<myModelItem*>(index.internalPointer());
213218
if(item) { return item->absoluteFilePath(); }
214219
return QString();
@@ -217,6 +222,7 @@ QString myModel::filePath(const QModelIndex &index)
217222
//---------------------------------------------------------------------------------------
218223
QString myModel::getMimeType(const QModelIndex &index)
219224
{
225+
if (!index.isValid()) { return QString(); }
220226
qDebug() << "myModel getMimeType";
221227
myModelItem *item = static_cast<myModelItem*>(index.internalPointer());
222228
if(item->mMimeType.isNull()) {
@@ -341,14 +347,13 @@ bool myModel::setRootPath(const QString& path)
341347
return false;
342348
}
343349

344-
if(item->watched == 0) { addWatcher(item); }
345-
346-
if(item->walked == 0) {
350+
if (!item->watched) { addWatcher(item); }
351+
if (!item->walked || !item->watched) {
347352
populateItem(item);
348353
return false;
349354
} else {
350355
if(item->dirty) { //model is up to date, but view needs to be invalidated
351-
item->dirty = 0;
356+
item->dirty = false;
352357
return true;
353358
}
354359
}
@@ -378,12 +383,10 @@ void myModel::fetchMore (const QModelIndex & parent)
378383
{
379384
myModelItem *item = static_cast<myModelItem*>(parent.internalPointer());
380385

381-
if(item) {
386+
if (item) {
382387
populateItem(item);
383388
emit dataChanged(parent,parent);
384389
}
385-
386-
return;
387390
}
388391

389392
//---------------------------------------------------------------------------------------
@@ -422,14 +425,15 @@ void myModel::refresh()
422425
watchers.clear();
423426

424427
beginResetModel();
425-
item->clearAll();
428+
if (item) { item->clearAll(); }
426429
endResetModel();
427430
}
428431

429432
//---------------------------------------------------------------------------------
430433
void myModel::update()
431434
{
432435
myModelItem *item = rootItem->matchPath(currentRootPath.split(SEPARATOR));
436+
if (item == NULL) { return; }
433437
foreach(myModelItem *child, item->children()) { child->refreshFileInfo(); }
434438
}
435439

@@ -619,7 +623,6 @@ void myModel::loadThumbs(QModelIndexList indexes) {
619623
if (!thumbs->contains(item) || (item.split("/").takeLast() == lastEventFilename && !lastEventFilename.isEmpty())) {
620624
qDebug() << "gen new thumb" << item;
621625
thumbs->insert(item, getThumb(item));
622-
emit thumbUpdate(index(item));
623626
if (item.split("/").takeLast() == lastEventFilename) {
624627
qDebug() << "save new thumb cache";
625628
lastEventFilename.clear();
@@ -634,10 +637,9 @@ void myModel::loadThumbs(QModelIndexList indexes) {
634637
}
635638
}
636639
}
637-
} else {
638-
emit thumbUpdate(index(item));
639640
}
640641
}
642+
emit thumbUpdate();
641643
}
642644
}
643645

@@ -650,6 +652,8 @@ void myModel::loadThumbs(QModelIndexList indexes) {
650652
*/
651653
QByteArray myModel::getThumb(QString item) {
652654

655+
if (item.isEmpty()) { return QByteArray(); }
656+
653657
// Thumbnail image
654658
QImage theThumb, background;
655659
QImageReader pic(item);
@@ -808,6 +812,8 @@ QVariant myModel::data(const QModelIndex & index, int role) const {
808812
*/
809813
QVariant myModel::findIcon(myModelItem *item) const {
810814

815+
if (item == NULL) { return QIcon(); }
816+
811817
//qDebug() << "findicon" << item->absoluteFilePath();
812818
// If type of file is directory, return icon of directory
813819
QFileInfo type(item->fileInfo());
@@ -891,6 +897,8 @@ QVariant myModel::findIcon(myModelItem *item) const {
891897
*/
892898
QVariant myModel::findMimeIcon(myModelItem *item) const {
893899

900+
if (item == NULL) { return QIcon(); }
901+
894902
// Retrieve mime and search cache for it
895903
QString mime = mimeUtilsPtr->getMimeType(item->absoluteFilePath());
896904
if (mimeIcons->contains(mime)) {

fm/src/mymodel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public slots:
8989
signals:
9090
void dragDropPaste(const QMimeData *data, QString newPath,
9191
Common::DragMode mode = Common::DM_UNKNOWN);
92-
void thumbUpdate(const QModelIndex index);
92+
void thumbUpdate();
9393
void reloadDir();
9494
protected:
9595
QVariant data(const QModelIndex & index, int role) const;

0 commit comments

Comments
 (0)