From 42b7a4faddb722769db2b50958120486d43261fc Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Tue, 10 Jan 2012 19:48:25 +0200 Subject: [PATCH 1/4] Update VS2008 project files. --- cli/cppcheck.vcproj | 22 +++++++++++++++++----- test/testrunner.vcproj | 36 ++++++++++++++++++++++++------------ 2 files changed, 41 insertions(+), 17 deletions(-) diff --git a/cli/cppcheck.vcproj b/cli/cppcheck.vcproj index cd313c031..7450d15f3 100755 --- a/cli/cppcheck.vcproj +++ b/cli/cppcheck.vcproj @@ -3,7 +3,7 @@ ProjectType="Visual C++" Version="9,00" Name="cppcheck" - ProjectGUID="{230A4467-25A6-3276-A1D0-CB521812CD43}" + ProjectGUID="{56B0F403-02CE-3F89-9A1B-E03F21240A63}" Keyword="Qt4VSv1.0"> + + + + + + + PreprocessorDefinitions="UNICODE,WIN32,QT_LARGEFILE_SUPPORT,HAVE_RULES,_CRT_SECURE_NO_WARNINGS,_DEBUG" /> + PreprocessorDefinitions="QT_NO_DEBUG,NDEBUG,UNICODE,WIN32,QT_LARGEFILE_SUPPORT,HAVE_RULES,_CRT_SECURE_NO_WARNINGS" /> @@ -135,6 +137,8 @@ RelativePath="..\lib\checkclass.cpp" /> + + + + + Date: Tue, 10 Jan 2012 21:16:47 +0200 Subject: [PATCH 2/4] GUI: Fix crash opening project file from command line. The GUI crashed if the project file was tried to open from the command line. The project file loading was run before the MRU menu was created but tried to add a new item to it. --- gui/mainwindow.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index c4d8a9e14..209e6b7ad 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -134,13 +134,8 @@ MainWindow::MainWindow() : EnableProjectOpenActions(true); EnableProjectActions(false); - QStringList args = QCoreApplication::arguments(); - //Remove the application itself - args.removeFirst(); - if (!args.isEmpty()) { - HandleCLIParams(args); - } - + // Must setup MRU menu before CLI param handling as it can load a + // project file and update MRU menu. for (int i = 0; i < MaxRecentProjects; ++i) { mRecentProjectActs[i] = new QAction(this); mRecentProjectActs[i]->setVisible(false); @@ -151,6 +146,13 @@ MainWindow::MainWindow() : mUI.mActionProjectMRU->setVisible(false); UpdateMRUMenuItems(); + QStringList args = QCoreApplication::arguments(); + //Remove the application itself + args.removeFirst(); + if (!args.isEmpty()) { + HandleCLIParams(args); + } + for (int i = 0; i < mPlatforms.getCount(); i++) { Platform plat = mPlatforms.mPlatforms[i]; QAction *act = new QAction(this); From c74e246e9b18e352f4012b34166a1fa85d90b698 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Tue, 10 Jan 2012 21:40:11 +0200 Subject: [PATCH 3/4] GUI: Remeber last path where project file was opened from. It is handy to remember the last location of the opened project file. Currently the Open Project -dialog was always opened to location of the executable file. Which is never the correct place. But last opened project file location might at least be near the location user wants to open next. Ticket: #3493 (GUI: remember last path in Open Project File) --- gui/common.h | 1 + gui/mainwindow.cpp | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/gui/common.h b/gui/common.h index c4471ff26..802d7178b 100644 --- a/gui/common.h +++ b/gui/common.h @@ -81,6 +81,7 @@ #define PROGRESS_MAX 1024.0 #define SETTINGS_CHECKED_PLATFORM "Checked platform" +#define SETTINGS_LAST_PROJECT_PATH "Last project path" /// @} #endif diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 209e6b7ad..5c91754ce 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -848,14 +848,19 @@ void MainWindow::OpenOnlineHelp() void MainWindow::OpenProjectFile() { + const QString lastPath = mSettings->value(SETTINGS_LAST_PROJECT_PATH, QString()).toString(); const QString filter = tr("Project files (*.cppcheck);;All files(*.*)"); - QString filepath = QFileDialog::getOpenFileName(this, - tr("Select Project File"), - QString(), - filter); + const QString filepath = QFileDialog::getOpenFileName(this, + tr("Select Project File"), + lastPath, + filter); if (!filepath.isEmpty()) { - LoadProjectFile(filepath); + const QFileInfo fi(filepath); + if (fi.exists() && fi.isFile() && fi.isReadable()) { + mSettings->setValue(SETTINGS_LAST_PROJECT_PATH, fi.path()); + LoadProjectFile(filepath); + } } } From cc92f1c4321e968eee24517ad1c928f055c16bbb Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Tue, 10 Jan 2012 22:14:51 +0200 Subject: [PATCH 4/4] GUI: Add include paths as relative to project file. When adding a new include path check if the path is relative path to the project file's path. If path is relative then remove the begin of the path making it a relative path in project file. Ticket: #3019 (GUI: Add project include paths as relative paths) --- gui/projectfiledialog.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gui/projectfiledialog.cpp b/gui/projectfiledialog.cpp index 36d6a199e..405e5bdc5 100644 --- a/gui/projectfiledialog.cpp +++ b/gui/projectfiledialog.cpp @@ -204,13 +204,23 @@ void ProjectFileDialog::SetExcludedPaths(const QStringList &paths) void ProjectFileDialog::AddIncludeDir() { - QFileInfo inf(mFilePath); + const QFileInfo inf(mFilePath); const QString rootpath = inf.absolutePath(); QString selectedDir = QFileDialog::getExistingDirectory(this, tr("Select include directory"), rootpath); if (!selectedDir.isEmpty()) { + // Check if the path is relative to project file's path and if so + // make it a relative path instead of absolute path. + const QDir dir(selectedDir); + QString absPath = dir.absolutePath(); + if (absPath.startsWith(rootpath)) { + // Remove also the slash from begin of new relative path + selectedDir = absPath.remove(0, rootpath.length() + 1); + } + if (!selectedDir.endsWith("/")) + selectedDir += '/'; AddIncludeDir(selectedDir); } }