Commit 3f44c6d0 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

ClearCase: Fix race condition

setStatus() is invoked in the main thread, but the
status change is tested for in the sync thread...

Change-Id: Ib322e12e7d40dafa6b60f3a73a202e8e1dcbfb53
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 691ade17
......@@ -81,6 +81,7 @@
#include <QMainWindow>
#include <QMenu>
#include <QMessageBox>
#include <QMetaObject>
#include <QMutex>
#include <QProcess>
#include <QRegExp>
......@@ -88,7 +89,6 @@
#include <QtConcurrentRun>
#include <QTemporaryFile>
#include <QTextCodec>
#include <QTimer>
#include <QtPlugin>
#include <QUrl>
#include <QUuid>
......@@ -642,11 +642,11 @@ void ClearCasePlugin::addCurrentFile()
vcsAdd(state.currentFileTopLevel(), state.relativeCurrentFile());
}
void ClearCasePlugin::setStatus(const QString &file, ClearCase::Internal::FileStatus::Status status, bool update)
void ClearCasePlugin::setStatus(const QString &file, FileStatus::Status status, bool update)
{
m_statusMap->insert(file, FileStatus(status, QFileInfo(currentState().topLevel(), file).permissions()));
if (update && (currentState().relativeCurrentFile() == file))
updateStatusActions();
QMetaObject::invokeMethod(this, "updateStatusActions");
}
void ClearCasePlugin::undoCheckOutCurrent()
......@@ -1940,8 +1940,6 @@ void ClearCasePlugin::sync(QFutureInterface<void> &future, QString topLevel, QSt
ClearCasePlugin *plugin = ClearCasePlugin::instance();
ClearCaseSync ccSync(plugin, plugin->m_statusMap);
connect(&ccSync, SIGNAL(updateStreamAndView()), plugin, SLOT(updateStreamAndView()));
connect(&ccSync, SIGNAL(setStatus(QString, ClearCase::Internal::FileStatus::Status, bool)),
plugin, SLOT(setStatus(QString, ClearCase::Internal::FileStatus::Status, bool)));
ccSync.run(future, topLevel, files);
}
......
......@@ -147,6 +147,7 @@ public:
QString currentView() const { return m_view; }
void refreshActivities();
inline bool isUcm() const { return m_isUcm; }
void setStatus(const QString &file, FileStatus::Status status, bool update = true);
bool ccCheckUcm(const QString &viewname, const QString &workingDir) const;
......@@ -155,7 +156,6 @@ public slots:
const QString &revision = QString(), int lineNumber = -1) const;
bool newActivity();
void updateStreamAndView();
void setStatus(const QString &file, ClearCase::Internal::FileStatus::Status status, bool update = true);
private slots:
void checkOutCurrentFile();
......@@ -180,6 +180,7 @@ private slots:
void tasksFinished(const QString &type);
void syncSlot();
void closing();
void updateStatusActions();
protected:
void updateActions(VcsBase::VcsBasePlugin::ActionState);
......@@ -210,7 +211,6 @@ private:
inline ClearCaseControl *clearCaseControl() const;
QString ccGetFileActivity(const QString &workingDir, const QString &file);
QStringList ccGetActivityVersions(const QString &workingDir, const QString &activity);
void updateStatusActions();
void diffGraphical(const QString &file1, const QString &file2 = QString());
QString diffExternal(QString file1, QString file2 = QString(), bool keep = false);
QString getFile(const QString &nativeFile, const QString &prefix);
......@@ -264,6 +264,4 @@ private:
} // namespace Internal
} // namespace ClearCase
Q_DECLARE_METATYPE(ClearCase::Internal::FileStatus::Status)
#endif // CLEARCASEPLUGIN_H
......@@ -87,7 +87,7 @@ void ClearCaseSync::run(QFutureInterface<void> &future, const QString &topLevel,
args << files;
} else {
foreach (const QString &file, files)
emit setStatus(topLevelDir.relativeFilePath(file), FileStatus::Unknown, false);
m_plugin->setStatus(topLevelDir.relativeFilePath(file), FileStatus::Unknown, false);
args << QLatin1String("-recurse");
args << vobs;
}
......@@ -120,15 +120,15 @@ void ClearCaseSync::run(QFutureInterface<void> &future, const QString &topLevel,
if (reState.indexIn(buffer, wspos + 1, QRegExp::CaretAtOffset) != -1) {
ccState = reState.cap();
if (ccState.indexOf(QLatin1String("hijacked")) != -1)
emit setStatus(file, FileStatus::Hijacked, true);
m_plugin->setStatus(file, FileStatus::Hijacked, true);
else if (ccState.indexOf(QLatin1String("loaded but missing")) != -1)
emit setStatus(file, FileStatus::Missing, false);
m_plugin->setStatus(file, FileStatus::Missing, false);
}
else if (buffer.lastIndexOf(QLatin1String("CHECKEDOUT"), wspos) != -1)
emit setStatus(file, FileStatus::CheckedOut, true);
m_plugin->setStatus(file, FileStatus::CheckedOut, true);
// don't care about checked-in files not listed in project
else if (m_statusMap->contains(file))
emit setStatus(file, FileStatus::CheckedIn, true);
m_plugin->setStatus(file, FileStatus::CheckedIn, true);
}
buffer.clear();
future.setProgressValue(qMin(total, ++processed));
......@@ -140,7 +140,7 @@ void ClearCaseSync::run(QFutureInterface<void> &future, const QString &topLevel,
foreach (const QString &file, files) {
QString relFile = topLevelDir.relativeFilePath(file);
if (m_statusMap->value(relFile).status == FileStatus::Unknown)
emit setStatus(relFile, FileStatus::NotManaged, false);
m_plugin->setStatus(relFile, FileStatus::NotManaged, false);
}
future.setProgressValue(total + 1);
if (!hot) {
......
......@@ -44,7 +44,6 @@ public:
signals:
void updateStreamAndView();
void setStatus(const QString &file, ClearCase::Internal::FileStatus::Status status, bool update);
private:
ClearCasePlugin *m_plugin;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment