From 23a3d3aa5b44cbdf305495919866d9dbf4f6da54 Mon Sep 17 00:00:00 2001 From: tpearson Date: Tue, 29 Jun 2010 18:51:09 +0000 Subject: Attempt to fix a race condition and subsequent crash git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeaddons@1144369 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- konq-plugins/dirfilter/dirfilterplugin.cpp | 24 ++++++++++++++++++++++++ konq-plugins/dirfilter/dirfilterplugin.h | 3 +++ 2 files changed, 27 insertions(+) diff --git a/konq-plugins/dirfilter/dirfilterplugin.cpp b/konq-plugins/dirfilter/dirfilterplugin.cpp index dbf034f..8401238 100644 --- a/konq-plugins/dirfilter/dirfilterplugin.cpp +++ b/konq-plugins/dirfilter/dirfilterplugin.cpp @@ -195,23 +195,43 @@ DirFilterPlugin::DirFilterPlugin (QObject* parent, const char* name, { QWhatsThis::add(m_searchWidget, i18n("Enter here a text which an item in the view must contain anywhere to be shown.")); connect(clear, SIGNAL(activated()), m_searchWidget, SLOT(clear())); + connect(m_searchWidget, SIGNAL(textChanged(const QString&)), this, SLOT(searchTextChanged(const QString&))); } KWidgetAction *filterAction = new KWidgetAction(hbox, i18n("Filter Field"), 0, 0, 0, actionCollection(), "toolbar_filter_field"); filterAction->setShortcutConfigurable(false); +// FIXME: This causes crashes for an unknown reason on certain systems +// Probably the iconview onchange event handler should tempoarily stop this timer before doing anything else +// Really the broken Qt3 iconview should just be modified to include a hidden list; it would make things *so* much easier! m_refreshTimer = new QTimer( this ); + m_reactivateRefreshTimer = new QTimer( this ); connect( m_refreshTimer, SIGNAL(timeout()), this, SLOT(activateSearch()) ); m_refreshTimer->start( 200, FALSE ); // 200 millisecond continuous timer + connect( m_reactivateRefreshTimer, SIGNAL(timeout()), this, SLOT(reactivateRefreshTimer()) ); } DirFilterPlugin::~DirFilterPlugin() { + m_reactivateRefreshTimer->stop(); m_refreshTimer->stop(); delete m_pFilterMenu; delete m_refreshTimer; + delete m_reactivateRefreshTimer; +} + +void DirFilterPlugin::searchTextChanged(const QString& newtext) +{ + m_refreshTimer->stop(); + m_reactivateRefreshTimer->stop(); + m_reactivateRefreshTimer->start( 1000, TRUE ); +} + +void DirFilterPlugin::reactivateRefreshTimer() +{ + m_refreshTimer->start( 200, FALSE ); // 200 millisecond continuous time } void DirFilterPlugin::slotOpenURL () @@ -474,6 +494,10 @@ void DirFilterPlugin::slotItemRemoved (const KFileItem* item) void DirFilterPlugin::activateSearch() { + // FIXME: If any of the files change while they are hidden in iconview mode, they will + // reappear under the wrong (old) name. This routine was originally intended to fix that + // problem, but will need to be able to detect when a change has occurred to be effective. + if (!m_searchWidget) return; diff --git a/konq-plugins/dirfilter/dirfilterplugin.h b/konq-plugins/dirfilter/dirfilterplugin.h index 963d731..c1313be 100644 --- a/konq-plugins/dirfilter/dirfilterplugin.h +++ b/konq-plugins/dirfilter/dirfilterplugin.h @@ -121,11 +121,14 @@ private slots: void slotItemRemoved(const KFileItem *); void slotItemsAdded(const KFileItemList &); void activateSearch(); + void searchTextChanged(const QString& newtext); + void reactivateRefreshTimer(); private: KURL m_pURL; KonqDirPart* m_part; QTimer *m_refreshTimer; + QTimer *m_reactivateRefreshTimer; KActionMenu* m_pFilterMenu; QString m_oldFilterString; -- cgit v1.2.1