From: Peter Penz Date: Sat, 14 Apr 2007 18:57:18 +0000 (+0000) Subject: assure that the preview job gets killed when the directory has been changed X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/e0bd6f137d90fea9854427f57f8945ecf38991eb assure that the preview job gets killed when the directory has been changed svn path=/trunk/KDE/kdebase/apps/; revision=653976 --- diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index d9e473ad1..47664da62 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -64,26 +64,27 @@ DolphinView::DolphinView(DolphinMainWindow* mainWindow, const KUrl& url, Mode mode, bool showHiddenFiles) : - QWidget(parent), - m_showProgress(false), - m_blockContentsMovedSignal(false), - m_mode(mode), - m_iconSize(0), - m_folderCount(0), - m_fileCount(0), - m_mainWindow(mainWindow), - m_topLayout(0), - m_urlNavigator(0), - m_controller(0), - m_iconsView(0), - m_detailsView(0), - m_columnView(0), - m_fileItemDelegate(0), - m_filterBar(0), - m_statusBar(0), - m_dirModel(0), - m_dirLister(0), - m_proxyModel(0) + QWidget(parent), + m_showProgress(false), + m_blockContentsMovedSignal(false), + m_mode(mode), + m_iconSize(0), + m_folderCount(0), + m_fileCount(0), + m_mainWindow(mainWindow), + m_topLayout(0), + m_urlNavigator(0), + m_controller(0), + m_iconsView(0), + m_detailsView(0), + m_columnView(0), + m_fileItemDelegate(0), + m_filterBar(0), + m_statusBar(0), + m_dirModel(0), + m_dirLister(0), + m_proxyModel(0), + m_previewJob(0) { hide(); setFocusPolicy(Qt::StrongFocus); @@ -177,6 +178,11 @@ DolphinView::DolphinView(DolphinMainWindow* mainWindow, DolphinView::~DolphinView() { + if (m_previewJob != 0) { + m_previewJob->doKill(); + m_previewJob = 0; + } + delete m_dirLister; m_dirLister = 0; } @@ -796,9 +802,14 @@ void DolphinView::updateItemCount() void DolphinView::generatePreviews(const KFileItemList& items) { if (m_controller->showPreview()) { - KIO::PreviewJob* job = KIO::filePreview(items, 128); - connect(job, SIGNAL(gotPreview(const KFileItem*, const QPixmap&)), + if (m_previewJob != 0) { + m_previewJob->doKill(); + } + m_previewJob = KIO::filePreview(items, 128); + connect(m_previewJob, SIGNAL(gotPreview(const KFileItem*, const QPixmap&)), this, SLOT(showPreview(const KFileItem*, const QPixmap&))); + connect(m_previewJob, SIGNAL(result(KJob*)), + this, SLOT(slotPreviewResult(KJob*))); } } @@ -879,6 +890,11 @@ void DolphinView::startDirLister(const KUrl& url, bool reload) m_blockContentsMovedSignal = true; m_dirLister->stop(); + if (m_previewJob != 0) { + m_previewJob->doKill(); + m_previewJob = 0; + } + bool openDir = true; bool keepOldDirs = isColumnViewActive(); if (keepOldDirs) { @@ -1147,6 +1163,12 @@ void DolphinView::updateCutItems() applyCutItemEffect(); } +void DolphinView::slotPreviewResult(KJob* job) +{ + Q_UNUSED(job); + m_previewJob = 0; +} + void DolphinView::createView() { // delete current view diff --git a/src/dolphinview.h b/src/dolphinview.h index f6b85f96b..aacb5e178 100644 --- a/src/dolphinview.h +++ b/src/dolphinview.h @@ -54,6 +54,11 @@ class QPainter; class QTimer; class ViewProperties; +namespace KIO +{ + class PreviewJob; +} + /** * @short Represents a view for the directory content * including the navigation bar, filter bar and status bar. @@ -521,6 +526,9 @@ private slots: /** Applies an item effect to all cut items of the clipboard. */ void updateCutItems(); + /** Is invoked when the preview job has been finished. */ + void slotPreviewResult(KJob* job); + private: void startDirLister(const KUrl& url, bool reload = false); @@ -615,6 +623,8 @@ private: DolphinDirLister* m_dirLister; DolphinSortFilterProxyModel* m_proxyModel; + KIO::PreviewJob* m_previewJob; + QList m_cutItemsCache; };