aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Shaforostoff <[email protected]>2015-09-13 00:31:08 +0300
committerNick Shaforostoff <[email protected]>2015-09-13 00:31:08 +0300
commit628aa5a1b9f67e21a5e12363af29e89957831317 (patch)
tree76d5ad0f97aa8e6a91c4ed61b5f02d1b057143b9
parentc95a0fa2246b889e1b88ac1a3e3836d910f762c4 (diff)
use QThreadPool::cancel() from Qt 5.5
-rw-r--r--src/filesearch/filesearchtab.cpp9
-rw-r--r--src/tm/tmscanapi.cpp4
-rw-r--r--src/tm/tmview.cpp28
-rw-r--r--src/tm/tmview.h2
4 files changed, 22 insertions, 21 deletions
diff --git a/src/filesearch/filesearchtab.cpp b/src/filesearch/filesearchtab.cpp
index acb33b9..b5513a6 100644
--- a/src/filesearch/filesearchtab.cpp
+++ b/src/filesearch/filesearchtab.cpp
@@ -627,10 +627,11 @@ void FileSearchTab::performSearch()
void FileSearchTab::stopSearch()
{
- QVector<QRunnable*>::const_iterator it;
- ///// KDE5PORT
- ////for (it = m_runningJobs.constBegin(); it != m_runningJobs.constEnd(); ++it)
- //// ThreadWeaver::Weaver::instance()->dequeue(*it);
+#if QT_VERSION >= 0x050500
+ int i=m_runningJobs.size();
+ while (--i>=0)
+ QThreadPool::globalInstance()->cancel(m_runningJobs.at(i));
+#endif
m_runningJobs.clear();
}
diff --git a/src/tm/tmscanapi.cpp b/src/tm/tmscanapi.cpp
index d3e0a0f..606172c 100644
--- a/src/tm/tmscanapi.cpp
+++ b/src/tm/tmscanapi.cpp
@@ -57,9 +57,9 @@ RecursiveScanJob::RecursiveScanJob(const QString& dbName, QObject* parent)
bool RecursiveScanJob::doKill()
{
-#if 0 //KDE5PORT
+#if QT_VERSION >= 0x050500
foreach(ScanJob* job, m_jobs)
- ThreadWeaver::Weaver::instance()->dequeue(job);
+ TM::threadPool()->cancel(job);
#endif
return true;
}
diff --git a/src/tm/tmview.cpp b/src/tm/tmview.cpp
index fb93392..ea09c3e 100644
--- a/src/tm/tmview.cpp
+++ b/src/tm/tmview.cpp
@@ -167,12 +167,10 @@ TMView::TMView(QWidget* parent, Catalog* catalog, const QVector<QAction*>& actio
TMView::~TMView()
{
-#if 0 //KDE5PORT set stop var of each job individually
+#if QT_VERSION >= 0x050500
int i=m_jobs.size();
while (--i>=0)
- TM::weaver()->dequeue(m_jobs.takeLast());
-#else
- m_jobs.clear();
+ TM::threadPool()->cancel(m_jobs.at(i));
#endif
}
@@ -227,13 +225,12 @@ void TMView::slotFileLoaded(const QString& filePath)
return;
m_cache.clear();
-#if 0 //KDE5PORT
+#if QT_VERSION >= 0x050500
int i=m_jobs.size();
while (--i>=0)
- TM::weaver()->dequeue(m_jobs.takeLast());
-#else
- m_jobs.clear();
+ TM::threadPool()->cancel(m_jobs.at(i));
#endif
+ m_jobs.clear();
DocPosition pos;
while(switchNext(m_catalog,pos))
@@ -301,7 +298,7 @@ void TMView::slotBatchSelectDone()
///m_catalog->push(new InsTextCmd(m_catalog,pos,entry.target));
insertCatalogString(m_catalog, pos, entry.target, 0);
- if (KDE_ISUNLIKELY( m_pos.entry==pos.entry&&pos.form==m_pos.form ))
+ if (Q_UNLIKELY( m_pos.entry==pos.entry&&pos.form==m_pos.form ))
emit refreshRequested();
}
@@ -362,8 +359,11 @@ void TMView::slotNewEntryDisplayed(const DocPosition& pos)
if (m_catalog->numberOfEntries()<=pos.entry)
return;//because of Qt::QueuedConnection
- //KDE5PORT set stop var individually
- //TM::weaver()->dequeue(m_currentSelectJob);
+#if QT_VERSION >= 0x050500
+ int i=m_jobs.size();
+ while (--i>=0)
+ TM::threadPool()->cancel(m_currentSelectJob);
+#endif
//update DB
//m_catalog->flushUpdateDBBuffer();
@@ -536,7 +536,7 @@ void TMView::slotSuggestionsCame(SelectJob* j)
html+=i?QStringLiteral("<br></p>"):QStringLiteral("</p>");
cur.insertHtml(html);
- if (KDE_ISUNLIKELY( ++i>=limit ))
+ if (Q_UNLIKELY( ++i>=limit ))
break;
cur.insertBlock(i%2?blockFormatAlternate:blockFormatBase);
@@ -978,7 +978,7 @@ nono
void TMView::slotUseSuggestion(int i)
{
- if (KDE_ISUNLIKELY( i>=m_entries.size() ))
+ if (Q_UNLIKELY( i>=m_entries.size() ))
return;
CatalogString target=targetAdapted(m_entries.at(i), m_catalog->sourceWithTags(m_pos));
@@ -991,7 +991,7 @@ void TMView::slotUseSuggestion(int i)
foreach (InlineTag tag, target.tags)
qWarning()<<"tag"<<tag.start<<tag.end;
#endif
- if (KDE_ISUNLIKELY( target.isEmpty() ))
+ if (Q_UNLIKELY( target.isEmpty() ))
return;
m_catalog->beginMacro(i18nc("@item Undo action","Use translation memory suggestion"));
diff --git a/src/tm/tmview.h b/src/tm/tmview.h
index 1e6a690..15fb296 100644
--- a/src/tm/tmview.h
+++ b/src/tm/tmview.h
@@ -103,7 +103,7 @@ private:
bool m_markAsFuzzy;
QMap<DocPos, QVector<TMEntry> > m_cache;
DocPosition m_prevCachePos;//hacky hacky
- QList<QRunnable*> m_jobs;//holds pointers to all the jobs for the current file
+ QVector<QRunnable*> m_jobs;//holds pointers to all the jobs for the current file
};
class TextBrowser: public QTextBrowser