# HG changeset patch # User Chris Cannam # Date 1294673645 0 # Node ID 4e98950f72e8f9e691a80a54ba6cd51b7682157b # Parent 53ad43d5a4631a021a8d1addd88dea4a9998b635 * Small simplification to watcher management diff -r 53ad43d5a463 -r 4e98950f72e8 mainwindow.cpp --- a/mainwindow.cpp Mon Jan 10 15:23:53 2011 +0000 +++ b/mainwindow.cpp Mon Jan 10 15:34:05 2011 +0000 @@ -49,7 +49,8 @@ MainWindow::MainWindow(QString myDirPath) : m_myDirPath(myDirPath), m_fsWatcherGeneralTimer(0), - m_fsWatcherRestoreTimer(0) + m_fsWatcherRestoreTimer(0), + m_fsWatcherSuspended(false) { setWindowIcon(QIcon(":images/easyhg-icon.png")); @@ -67,6 +68,8 @@ createStatusBar(); runner = new HgRunner(myDirPath, this); + connect(runner, SIGNAL(commandStarting(HgAction)), + this, SLOT(commandStarting(HgAction))); connect(runner, SIGNAL(commandCompleted(HgAction, QString)), this, SLOT(commandCompleted(HgAction, QString))); connect(runner, SIGNAL(commandFailed(HgAction, QString)), @@ -896,6 +899,10 @@ stateUnknown = true; needNewLog = true; if (fsWatcher) { + delete m_fsWatcherGeneralTimer; + m_fsWatcherGeneralTimer = 0; + delete m_fsWatcherRestoreTimer; + m_fsWatcherRestoreTimer = 0; delete fsWatcher; fsWatcher = 0; } @@ -1421,9 +1428,12 @@ { DEBUG << "MainWindow::suspendFileSystemWatcher" << endl; if (fsWatcher) { - m_fsWatcherRestoreTimer->stop(); + m_fsWatcherSuspended = true; + if (m_fsWatcherRestoreTimer) { + delete m_fsWatcherRestoreTimer; + m_fsWatcherRestoreTimer = 0; + } m_fsWatcherGeneralTimer->stop(); - fsWatcher->blockSignals(true); } } @@ -1449,7 +1459,10 @@ void MainWindow::actuallyRestoreFileSystemWatcher() { DEBUG << "MainWindow::actuallyRestoreFileSystemWatcher" << endl; - if (fsWatcher) fsWatcher->blockSignals(false); + if (fsWatcher) { + m_fsWatcherSuspended = false; + m_fsWatcherGeneralTimer->start(); + } } void MainWindow::checkFilesystem() @@ -1461,13 +1474,17 @@ void MainWindow::fsDirectoryChanged(QString d) { DEBUG << "MainWindow::fsDirectoryChanged " << d << endl; - hgStat(); + if (!m_fsWatcherSuspended) { + hgStat(); + } } void MainWindow::fsFileChanged(QString f) { DEBUG << "MainWindow::fsFileChanged " << f << endl; - hgStat(); + if (!m_fsWatcherSuspended) { + hgStat(); + } } QString MainWindow::format3(QString head, QString intro, QString code) diff -r 53ad43d5a463 -r 4e98950f72e8 mainwindow.h --- a/mainwindow.h Mon Jan 10 15:23:53 2011 +0000 +++ b/mainwindow.h Mon Jan 10 15:34:05 2011 +0000 @@ -218,6 +218,7 @@ QFileSystemWatcher *fsWatcher; QTimer *m_fsWatcherGeneralTimer; QTimer *m_fsWatcherRestoreTimer; + bool m_fsWatcherSuspended; QString lastStatOutput; QStringList lastRevertedFiles;