OneMoreGres / qtc-cppcheck

Qt Creator Cppcheck integration plugin [deprecated]
MIT License
127 stars 37 forks source link

qtc-cppcheck doesn't build against QtCreator 3.4.0RC1 (partial patch included) #11

Closed ghost closed 9 years ago

ghost commented 9 years ago

Several compile errors when building qtc-cppcheck against the source of QtCreator 3.4.0RC1.

I fixed the compile errors with the attached patch, but when running the plugin the following assert in function void CppcheckRunner::checkQueuedFiles() fails:

QString binary = settings_->binaryFile (); Q_ASSERT (!binary.isEmpty ());

ghost commented 9 years ago
diff --git a/src/QtcCppcheckPlugin.cpp b/src/QtcCppcheckPlugin.cpp
index 77b7b87..5d597a6 100644
--- a/src/QtcCppcheckPlugin.cpp
+++ b/src/QtcCppcheckPlugin.cpp
@@ -7,6 +7,7 @@
 #include <coreplugin/actionmanager/actioncontainer.h>
 #include <coreplugin/coreconstants.h>
 #include <coreplugin/editormanager/editormanager.h>
+#include <coreplugin/idocument.h>

 #include <projectexplorer/projectexplorer.h>
 #include <projectexplorer/projectnodes.h>
@@ -14,6 +15,7 @@
 #include <projectexplorer/taskhub.h>
 #include <projectexplorer/buildmanager.h>
 #include <projectexplorer/session.h>
+#include <projectexplorer/projecttree.h>

 #include <QtPlugin>

@@ -23,6 +25,7 @@
 #include "OptionsPage.h"
 #include "TaskInfo.h"
 #include "CppcheckRunner.h"
+#include <QMenu>

 using namespace QtcCppcheck::Internal;

@@ -45,7 +48,7 @@ namespace
   bool isFileNodeCheckable (const FileNode* node)
   {
     static QStringList extensions = supportedExtensions ();
-    QFileInfo info (node->path());
+    QFileInfo info (node->path().toString());
     QString extension = info.completeSuffix ();
     return (extensions.contains (extension));
   }
@@ -212,7 +215,7 @@ void QtcCppcheckPlugin::checkCurrentDocument()
     return;
   }
   // Check event if it not belongs to active project.
-  checkFiles (QStringList () << document->filePath ());
+  checkFiles (QStringList () << document->filePath().toString());
 }

 void QtcCppcheckPlugin::checkActiveProject()
@@ -225,7 +228,8 @@ void QtcCppcheckPlugin::checkActiveProject()

 void QtcCppcheckPlugin::checkCurrentNode()
 {
-  Node* node = ProjectExplorerPlugin::instance ()->currentNode ();
+  //Node* node = ProjectExplorerPlugin::instance ()->currentNode ();
+  Node* node = ProjectTree::currentNode();
   if (node == NULL)
   {
     return;
@@ -248,7 +252,7 @@ QStringList QtcCppcheckPlugin::checkableFiles(const Node *node, bool forceSelect
       const FileNode* file = (const FileNode*) node;
       if (forceSelected || isFileNodeCheckable (file))
       {
-        files << file->path ();
+        files << file->path().toString();
       }
     }
       break;
@@ -390,10 +394,10 @@ void QtcCppcheckPlugin::checkActiveProjectDocuments(int beginRow, int endRow,
     {
       continue;
     }
-    if (projectFileList_.contains (document->filePath ()) &&
+    if (projectFileList_.contains (document->filePath().toString()) &&
         document->isModified () == modifiedFlag)
     {
-      filesToCheck << document->filePath ();
+      filesToCheck << document->filePath().toString();
     }
   }
OneMoreGres commented 9 years ago

I'll watch for it when QTC 3.4 will be officially released. Looks like assert triggers because binary file has not been set in plugin's options. It should be just a check, not an assertion. So you can safely replace it with if/return.

ghost commented 9 years ago

Ah, yes, you are right. When I fill in the path of cppcheck in the options dialog, the assert does not occur.

So looks like the attached patch is all that is needed for QtCreator 3.4.0RC1 .

OneMoreGres commented 9 years ago

Source updated. Thanks for patch.