Skip to content
This repository has been archived by the owner on Jan 2, 2020. It is now read-only.

Commit

Permalink
Merge PR
Browse files Browse the repository at this point in the history
  • Loading branch information
OneMoreGres committed Jul 18, 2018
2 parents 3969594 + 860c2f6 commit f4b04f5
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 46 deletions.
33 changes: 16 additions & 17 deletions src/CppcheckRunner.cpp
Expand Up @@ -36,20 +36,20 @@ CppcheckRunner::CppcheckRunner (Settings *settings, QObject *parent) :
#endif
Q_ASSERT (settings_ != NULL);

connect (&process_, SIGNAL (readyReadStandardOutput ()),
SLOT (readOutput ()));
connect (&process_, SIGNAL (readyReadStandardError ()),
SLOT (readError ()));
connect (&process_, SIGNAL (started ()),
SLOT (started ()));
connect (&process_, SIGNAL (error (QProcess::ProcessError)),
SLOT (error (QProcess::ProcessError)));
connect (&process_, SIGNAL (finished (int,QProcess::ExitStatus)),
SLOT (finished (int,QProcess::ExitStatus)));
connect (&process_, &QProcess::readyReadStandardOutput,
this, &CppcheckRunner::readOutput);
connect (&process_, &QProcess::readyReadStandardError,
this, &CppcheckRunner::readError);
connect (&process_, &QProcess::started,
this, &CppcheckRunner::started);
connect (&process_, &QProcess::errorOccurred,
this, &CppcheckRunner::error);
connect (&process_, static_cast<void (QProcess::*)(int)>(&QProcess::finished),
this, &CppcheckRunner::finished);

// Restart checking if got queue.
connect (&process_, SIGNAL (finished (int,QProcess::ExitStatus)),
SLOT (checkQueuedFiles ()));
connect (&process_, static_cast<void (QProcess::*)(int)>(&QProcess::finished),
this, &CppcheckRunner::checkQueuedFiles);
}

CppcheckRunner::~CppcheckRunner () {
Expand Down Expand Up @@ -112,7 +112,7 @@ void CppcheckRunner::checkFiles (const QStringList &fileNames) {
// Delay helps to avoid double checking same file on editor change.
const int checkDelayInMs = 200;
if (!queueTimer_.isActive ()) {
queueTimer_.singleShot (checkDelayInMs, this, SLOT (checkQueuedFiles ()));
queueTimer_.singleShot (checkDelayInMs, this, &CppcheckRunner::checkQueuedFiles);
}
}

Expand Down Expand Up @@ -245,7 +245,7 @@ void CppcheckRunner::started () {
futureInterface_ = new QFutureInterface<void>;
FutureProgress *progress = ProgressManager::addTask (futureInterface_->future (),
tr ("Cppcheck"), Constants::TASK_CHECKING);
connect (progress, SIGNAL (canceled ()), SLOT (stopChecking ()));
connect (progress, &Core::FutureProgress::canceled, this, &CppcheckRunner::stopChecking);
futureInterface_->setProgressRange (0, 100); // %
futureInterface_->reportStarted ();
}
Expand All @@ -256,13 +256,12 @@ void CppcheckRunner::error (QProcess::ProcessError error) {
Core::MessageManager::write (tr ("Cppcheck error occured"), Core::MessageManager::Silent);
}
if (error == QProcess::FailedToStart) {
finished (-1, QProcess::CrashExit);
finished (-1);
}
}

void CppcheckRunner::finished (int exitCode, QProcess::ExitStatus exitStatus) {
void CppcheckRunner::finished (int exitCode) {
Q_UNUSED (exitCode);
Q_UNUSED (exitStatus);
if (futureInterface_ != NULL) {
futureInterface_->reportFinished ();
}
Expand Down
2 changes: 1 addition & 1 deletion src/CppcheckRunner.h
Expand Up @@ -52,7 +52,7 @@ namespace QtcCppcheck {
void readError ();
void started ();
void error (QProcess::ProcessError error);
void finished (int exitCode, QProcess::ExitStatus exitStatus);
void finished (int exitCode);

private:
//! Timer to delay queue checking.
Expand Down
5 changes: 3 additions & 2 deletions src/OptionsWidget.cpp
Expand Up @@ -27,8 +27,9 @@ OptionsWidget::OptionsWidget (Settings *settings, QWidget *parent) :
auto chooser = new Core::VariableChooser (this);
chooser->addSupportedWidget (ui->customParametersEdit);

connect (ui->getHelpButton, SIGNAL (clicked ()), SLOT (getPossibleParams ()));
connect (&process_, SIGNAL (finished (int,QProcess::ExitStatus)), SLOT (finished ()));
connect (ui->getHelpButton, &QAbstractButton::clicked, this, &OptionsWidget::getPossibleParams);
connect (&process_, static_cast<void (QProcess::*)(int)>(&QProcess::finished),
this, &OptionsWidget::finished);

initInterface ();
}
Expand Down
47 changes: 21 additions & 26 deletions src/QtcCppcheckPlugin.cpp
Expand Up @@ -104,7 +104,7 @@ bool QtcCppcheckPlugin::initialize (const QStringList &arguments, QString *error
updateSettings ();

OptionsPage *optionsPage = new OptionsPage (settings_, this);
connect (optionsPage, SIGNAL (settingsChanged ()), SLOT (updateSettings ()));
connect (optionsPage, &OptionsPage::settingsChanged, this, &QtcCppcheckPlugin::updateSettings);

initMenus ();
initConnections ();
Expand All @@ -116,7 +116,7 @@ void QtcCppcheckPlugin::initMenus () {
Command *checkNodeCmd = ActionManager::registerAction (
checkNodeAction, Constants::ACTION_CHECK_NODE_ID,
Context (Core::Constants::C_EDIT_MODE));
connect (checkNodeAction, SIGNAL (triggered ()), this, SLOT (checkCurrentNode ()));
connect (checkNodeAction, &QAction::triggered, this, &QtcCppcheckPlugin::checkCurrentNode);

using namespace ProjectExplorer::Constants;
addToMenu (checkNodeCmd, M_FILECONTEXT, G_FILE_OTHER);
Expand All @@ -129,14 +129,14 @@ void QtcCppcheckPlugin::initMenus () {
checkProjectAction, Constants::ACTION_CHECK_PROJECT_ID,
Context (Core::Constants::C_GLOBAL));
checkProjectCmd->setDefaultKeySequence (QKeySequence (tr ("Alt+C,Ctrl+A")));
connect (checkProjectAction, SIGNAL (triggered ()), this, SLOT (checkActiveProject ()));
connect (checkProjectAction, &QAction::triggered, this, &QtcCppcheckPlugin::checkActiveProject);

QAction *checkDocumentAction = new QAction (tr ("Check current &document"), this);
Command *checkDocumentCmd = ActionManager::registerAction (
checkDocumentAction, Constants::ACTION_CHECK_DOCUMENT_ID,
Context (Core::Constants::C_GLOBAL));
checkDocumentCmd->setDefaultKeySequence (QKeySequence (tr ("Alt+C,Ctrl+D")));
connect (checkDocumentAction, SIGNAL (triggered ()), this, SLOT (checkCurrentDocument ()));
connect (checkDocumentAction, &QAction::triggered, this, &QtcCppcheckPlugin::checkCurrentDocument);


ActionContainer *menu = ActionManager::createMenu (Constants::MENU_ID);
Expand All @@ -147,31 +147,26 @@ void QtcCppcheckPlugin::initMenus () {
}

void QtcCppcheckPlugin::initConnections () {
connect (runner_, SIGNAL (newTask (char,const QString&,const QString&,const QString&,int)),
SLOT (addTask (char,const QString&,const QString&,const QString&,int)));
connect (runner_, SIGNAL (startedChecking (const QStringList&)),
SLOT (clearTasksForFiles (const QStringList&)));
connect (runner_, &CppcheckRunner::newTask,
this, &QtcCppcheckPlugin::addTask);
connect (runner_, &CppcheckRunner::startedChecking,
this, &QtcCppcheckPlugin::clearTasksForFiles);

connect (SessionManager::instance (),
SIGNAL (aboutToUnloadSession (QString)),
SLOT (handleSessionUnload ()));
connect (SessionManager::instance (), &SessionManager::aboutToUnloadSession,
this, &QtcCppcheckPlugin::handleSessionUnload);

connect (SessionManager::instance (),
SIGNAL (startupProjectChanged (ProjectExplorer::Project *)),
SLOT (handleStartupProjectChange (ProjectExplorer::Project *)));
connect (SessionManager::instance (), &SessionManager::startupProjectChanged,
this, &QtcCppcheckPlugin::handleStartupProjectChange);

// Check on build
connect (BuildManager::instance (),
SIGNAL (buildStateChanged (ProjectExplorer::Project *)),
SLOT (handleBuildStateChange (ProjectExplorer::Project *)));
connect (BuildManager::instance (), &BuildManager::buildStateChanged,
this, &QtcCppcheckPlugin::handleBuildStateChange);

// Open documents auto check.
connect (DocumentModel::model (),
SIGNAL (dataChanged (const QModelIndex&,const QModelIndex&,const QVector<int> &)),
SLOT (handleDocumentsChange (const QModelIndex&,const QModelIndex&,const QVector<int> &)));
connect (DocumentModel::model (),
SIGNAL (rowsAboutToBeRemoved (const QModelIndex&,int,int)),
SLOT (handleDocumentsClose (const QModelIndex&,int,int)));
connect (DocumentModel::model (), &QAbstractItemModel::dataChanged,
this, &QtcCppcheckPlugin::handleDocumentsChange);
connect (DocumentModel::model (), &QAbstractItemModel::rowsAboutToBeRemoved,
this, &QtcCppcheckPlugin::handleDocumentsClose);
}

void QtcCppcheckPlugin::initLanguage () {
Expand Down Expand Up @@ -304,8 +299,8 @@ void QtcCppcheckPlugin::updateProjectFileList () {

void QtcCppcheckPlugin::handleStartupProjectChange (Project *project) {
if (!activeProject_.isNull ()) {
disconnect (activeProject_.data (), SIGNAL (fileListChanged ()),
this, SLOT (handleProjectFileListChanged ()));
disconnect (activeProject_.data (), &Project::fileListChanged,
this, &QtcCppcheckPlugin::handleProjectFileListChanged);
}
activeProject_ = project;
handleProjectFileListChanged ();
Expand All @@ -314,7 +309,7 @@ void QtcCppcheckPlugin::handleStartupProjectChange (Project *project) {
if (project == NULL) {
return;
}
connect (project, SIGNAL (fileListChanged ()), SLOT (handleProjectFileListChanged ()));
connect (project, &Project::fileListChanged, this, &QtcCppcheckPlugin::handleProjectFileListChanged);

Q_ASSERT (settings_ != NULL);
if (settings_->checkOnProjectChange ()) {
Expand Down

0 comments on commit f4b04f5

Please sign in to comment.