views/renamedialog.cpp
views/tooltips/filemetadatatooltip.cpp
views/tooltips/tooltipmanager.cpp
- views/versioncontrol/pendingthreadsmaintainer.cpp
views/versioncontrol/updateitemstatesthread.cpp
views/versioncontrol/versioncontrolobserver.cpp
views/viewmodecontroller.cpp
+++ /dev/null
-/***************************************************************************
- * Copyright (C) 2010 by Peter Penz <peter.penz19@gmail.com> *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
- ***************************************************************************/
-
-#include "pendingthreadsmaintainer.h"
-
-#include <KGlobal>
-#include <QThread>
-#include <QTimer>
-
-struct PendingThreadsMaintainerSingleton
-{
- PendingThreadsMaintainer instance;
-};
-K_GLOBAL_STATIC(PendingThreadsMaintainerSingleton, s_pendingThreadsMaintainer)
-
-
-PendingThreadsMaintainer& PendingThreadsMaintainer::instance()
-{
- return s_pendingThreadsMaintainer->instance;
-}
-
-PendingThreadsMaintainer::~PendingThreadsMaintainer()
-{
-}
-
-void PendingThreadsMaintainer::append(QThread* thread)
-{
- Q_ASSERT(thread);
- m_threads.append(thread);
- m_timer->start();
-}
-
-PendingThreadsMaintainer::PendingThreadsMaintainer() :
- QObject(),
- m_threads(),
- m_timer(0)
-{
- m_timer = new QTimer(this);
- m_timer->setSingleShot(true);
- m_timer->setInterval(5000); // 5 seconds
- connect(m_timer, SIGNAL(timeout()), this, SLOT(cleanup()));
-}
-
-void PendingThreadsMaintainer::cleanup()
-{
- QList<QThread*>::iterator it = m_threads.begin();
- while (it != m_threads.end()) {
- if ((*it)->isFinished()) {
- (*it)->deleteLater();
- it = m_threads.erase(it);
- } else {
- ++it;
- }
- }
-
- if (!m_threads.isEmpty()) {
- m_timer->start();
- }
-}
-
-#include "pendingthreadsmaintainer.moc"
+++ /dev/null
-/***************************************************************************
- * Copyright (C) 2010 by Peter Penz <peter.penz19@gmail.com> *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
- ***************************************************************************/
-
-#ifndef PENDINGTHREADSMAINTAINER_H
-#define PENDINGTHREADSMAINTAINER_H
-
-#include <libdolphin_export.h>
-
-#include <QObject>
-
-class QTimer;
-
-/**
- * TODO: Replace the PendingThreadMaintainer by a kind of
- * VersionControlThreadFactory that is responsible for creating
- * and deleting the threads. This would bypass the hack to poll
- * for pending threads.
- *
- * If the creator of a thread gets deleted, although the thread is still
- * working, usually QThread::wait() is invoked. The drawback of this
- * approach is that the user interface gets blocked for an undefined amount
- * of time. If the thread does not contain references to the creator, the
- * deleting can be forwarded to the PendingThreadsMaintainer. In the following
- * example it is assumed, that m_thread will be 0, if it has been deleted by the
- * creator after receiving the signal QThread::finished():
- *
- * \code
- * ThreadCreator::~ThreadCreator()
- * {
- * if (m_thread) {
- * PendingThreadsMaintainer::instance().append(m_thread);
- * m_thread = 0;
- * }
- * }
- * \endcode
- *
- * The thread will get automatically deleted after it (or has already) been finished.
- *
- * Implementation note: Connecting to the signal QThread::finished() is
- * not sufficient, as it is possible that the thread has already emitted
- * the signal, but the signal has not been received yet by the thread creator.
- * Because of this a polling is done each 5 seconds to check, whether the
- * thread has been finished.
- */
-class LIBDOLPHINPRIVATE_EXPORT PendingThreadsMaintainer : public QObject
-{
- Q_OBJECT
-
-public:
- static PendingThreadsMaintainer& instance();
- virtual ~PendingThreadsMaintainer();
-
- /**
- * Appends the thread \p thread to the maintainer. The thread
- * will be deleted by the maintainer after it has been finished.
- */
- void append(QThread* thread);
-
-protected:
- PendingThreadsMaintainer();
-
-private slots:
- void cleanup();
-
-private:
- QList<QThread*> m_threads;
- QTimer* m_timer;
-
- friend class PendingThreadsMaintainerSingleton;
-};
-
-#endif
#include <kitemviews/kfileitemmodel.h>
#include <kversioncontrolplugin.h>
-#include "pendingthreadsmaintainer.h"
#include "updateitemstatesthread.h"
#include <QMutexLocker>
VersionControlObserver::~VersionControlObserver()
{
- if (m_updateItemStatesThread) {
- if (m_updateItemStatesThread->isFinished()) {
- delete m_updateItemStatesThread;
- m_updateItemStatesThread = 0;
- } else {
- // The version controller gets deleted, while a thread still
- // is working to get the version information. To avoid a blocking
- // user interface, the thread will be forwarded to the
- // PendingThreadsMaintainer, which will delete the thread later.
- disconnect(m_updateItemStatesThread, SIGNAL(finished()),
- this, SLOT(slotThreadFinished()));
- PendingThreadsMaintainer::instance().append(m_updateItemStatesThread);
- m_updateItemStatesThread = 0;
- }
- }
-
if (m_plugin) {
- m_plugin->disconnect();
+ m_plugin->disconnect(this);
m_plugin = 0;
}
}
}
if (m_plugin) {
- m_plugin->disconnect();
+ m_plugin->disconnect(this);
}
m_plugin = searchPlugin(versionControlUrl);
void VersionControlObserver::slotThreadFinished()
{
+ UpdateItemStatesThread* thread = m_updateItemStatesThread;
+ m_updateItemStatesThread = 0; // The thread deletes itself automatically (see updateItemStates())
+
if (!m_plugin) {
return;
}
- if (!m_updateItemStatesThread->retrievedItems()) {
+ if (!thread->retrievedItems()) {
// Ignore m_silentUpdate for an error message
emit errorMessage(i18nc("@info:status", "Update of version information failed."));
return;
}
- const QList<ItemState> itemStates = m_updateItemStatesThread->itemStates();
+ const QList<ItemState> itemStates = thread->itemStates();
foreach (const ItemState& itemState, itemStates) {
QHash<QByteArray, QVariant> values;
values.insert("version", QVariant(itemState.version));
m_updateItemStatesThread = new UpdateItemStatesThread();
connect(m_updateItemStatesThread, SIGNAL(finished()),
this, SLOT(slotThreadFinished()));
+ connect(m_updateItemStatesThread, SIGNAL(finished()),
+ m_updateItemStatesThread, SLOT(deleteLater()));
}
if (m_updateItemStatesThread->isRunning()) {
// An update is currently ongoing. Wait until the thread has finished
// Verify whether the current directory contains revision information
// like .svn, .git, ...
- Q_UNUSED(directory);
foreach (KVersionControlPlugin* plugin, plugins) {
// Use the KDirLister cache to check for .svn, .git, ... files
const QString fileName = directory.path(KUrl::AddTrailingSlash) + plugin->fileName();