summaryrefslogtreecommitdiffstats
path: root/filesystemwidget.cpp
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2013-07-29 10:08:33 +0200
committerArno <am@disconnect.de>2013-07-29 10:08:33 +0200
commit06cfadc8386aec27b9c7c43486fc0b057e9fb022 (patch)
treeca0343db7f3363fb35bd4fc0ea72779651e0361e /filesystemwidget.cpp
parent28c7436a71910aabcc37945255fb577f7a032f0d (diff)
downloadSheMov-06cfadc8386aec27b9c7c43486fc0b057e9fb022.tar.gz
SheMov-06cfadc8386aec27b9c7c43486fc0b057e9fb022.tar.bz2
SheMov-06cfadc8386aec27b9c7c43486fc0b057e9fb022.zip
Prevent datacollector from running when operating on files
This stuff was racy from the beginning. It could happen that the model got reset after we fetched the selected indexes. Add a mutex and lock it before operating on the file view. Hopefully this will many, if not all random crashes.
Diffstat (limited to 'filesystemwidget.cpp')
-rw-r--r--filesystemwidget.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/filesystemwidget.cpp b/filesystemwidget.cpp
index 4c05640..79ef2ab 100644
--- a/filesystemwidget.cpp
+++ b/filesystemwidget.cpp
@@ -163,6 +163,7 @@ void FilesystemWidget::directoryEdited(){
}
void FilesystemWidget::fileViewActivated(const QModelIndex &idx){
+ QMutexLocker l(&mFileModel->collector()->hold());
QModelIndex real = mFileProxy->mapToSource(idx);
if(mFileModel->isDir(real)){
if(idx.data().toString() == ".."){
@@ -216,6 +217,7 @@ void FilesystemWidget::goBack(){
}
void FilesystemWidget::deleteFiles(){
+ QMutexLocker l(&mFileModel->collector()->hold());
QSortFilterProxyModel *proxy = qobject_cast<QSortFilterProxyModel*>(mFileView->model());
QModelIndexList selected = mFileView->selectionModel()->selectedRows();
if(selected.isEmpty()){
@@ -233,6 +235,7 @@ void FilesystemWidget::deleteFiles(){
}
void FilesystemWidget::toClipboard(int clipmode){
+ QMutexLocker l(&mFileModel->collector()->hold());
mClipboardMode = clipmode;
QClipboard *clip = qApp->clipboard();
QModelIndexList selected = mFileView->selectionModel()->selectedRows();
@@ -309,6 +312,7 @@ void FilesystemWidget::playSelected(const QString &player){
}
void FilesystemWidget::readSettings(){
+ QMutexLocker l(&mFileModel->collector()->hold());
QSettings s;
QStringList expandedDirs = s.value("paths/expandeddirs").toStringList();
if(expandedDirs.isEmpty()){
@@ -337,6 +341,7 @@ void FilesystemWidget::readSettings(){
}
void FilesystemWidget::writeSettings(){
+ QMutexLocker l(&mFileModel->collector()->hold());
QSettings s;
s.setValue("paths/expandeddirs", mExpandedDirs);
QModelIndex currentDir = mDirView->selectionModel()->currentIndex();
@@ -356,6 +361,7 @@ void FilesystemWidget::configChanged(){
}
void FilesystemWidget::dvdMount(){
+ QMutexLocker l(&mFileModel->collector()->hold());
QSettings s;
QString mountDir = s.value("paths/dvdmount").toString();
if(isMounted()){
@@ -414,6 +420,7 @@ void FilesystemWidget::selectAllPV(){
}
void FilesystemWidget::setWindowTitle(){
+ QMutexLocker l(&mFileModel->collector()->hold());
QModelIndex curIdx = mDirView->selectionModel()->currentIndex();
QString dir = curIdx.data(QFileSystemModel::FilePathRole).toString();
mWindowTitle = QString(tr("Filemanager - [%1]")).arg(dir);
@@ -501,6 +508,7 @@ void FilesystemWidget::copyRecursive(const QFileInfo &start, const QString &dest
}
const QString FilesystemWidget::selectedDir(){
+ QMutexLocker l(&mFileModel->collector()->hold());
const QModelIndexList selected = mDirView->selectionModel()->selectedRows();
if(!selected.isEmpty()){
return selected.at(0).data(QFileSystemModel::FilePathRole).toString();