OneMoreGres / qtc-cppcheck

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

Qt5 + QtCreator 3.1.2 porting issue #3

Closed RiseOfDeath closed 10 years ago

RiseOfDeath commented 10 years ago

Не успешная попытка адаптировать плагин под QtCreator 3.x.x и Qt5.

Что я менял:

paths.pri - согласно моим путям (и убрал обработку виндовых компиляторов, что бы не отвлекала внимание):

QTCREATOR_VERSION = 3.1.2

## set the QTC_SOURCE environment variable to override the setting here
QTCREATOR_SOURCES = $$(QTC_SOURCE)
isEmpty(QTCREATOR_SOURCES):QTCREATOR_SOURCES=/home/anton/workspace/qt-creator-5/qt-creator/

## set the QTC_BUILD environment variable to override the setting here
IDE_BUILD_TREE = $$(QTC_BUILD)
isEmpty(IDE_BUILD_TREE):IDE_BUILD_TREE=/home/anton/Qt/Tools/QtCreator

Также заменил инклуды согласно The Transition from Qt 4.x to Qt 5 в файлах:

OptionsWidget.h

- #include <QWidget>
+ #include <QtWidgets/QWidget>

OptionsWidget.cpp

- #include <QFileDialog>
+ #include <QtWidgets/QFileDialog>
- #include <QTextEdit>
+ #include <QtWidgets/QTextEdit>

Других изменений в исходники я не вносил.

В результате при компиляции выдает:

src/QtcCppcheckPlugin.cpp: In member function 'void QtcCppcheck::Internal::QtcCppcheckPlugin::initConnections()': src/QtcCppcheckPlugin.cpp:145:12: error: 'documentModel' is not a member of 'Core::EditorManager' src/QtcCppcheckPlugin.cpp:148:12: error: 'documentModel' is not a member of 'Core::EditorManager' src/QtcCppcheckPlugin.cpp: In member function 'void QtcCppcheck::Internal::QtcCppcheckPlugin::checkActiveProjectDocuments(int, int, bool)': src/QtcCppcheckPlugin.cpp:360:26: error: 'documentModel' is not a member of 'Core::EditorManager' src/QtcCppcheckPlugin.cpp:365:42: error: 'class Core::DocumentModel' has no member named 'documentAtRow'

Подозреваю что QtCreator 3.x.x внутри чем-то отличается от более старых версий.

OneMoreGres commented 10 years ago

Ты точно 3.1.2 собираешь? По ошибкам больше похоже на master ветку. Если да, то там их еще несколько будет :) С 3.2 (да и вообще с 3.1.2+) я совместимость пока не проверял, т.к. версия еще не финальная и может меняться. Буду пересобирать после официального релиза. Но вопросы по ней мне уже задавали, так что на всякий случай выложу мои на них ответы (несколько выдраны из контекста). Ответы на скорую руку + где-то 3-недельной давности, так что может еще что-то неприятное всплыть.

(documentModel not a member...): вместо EditorManager::documentModel () написать DocumentModel::model()

(DocumentModel has no member...): DocumentModel::Entry* entry = model->documentAtRow (row); заменить на DocumentModel::Entry* entry = model->entryAtRow(row);

вместо DocumentModel* model = EditorManager::documentModel (); надо написать QAbstractItemModel* model = EditorManager::documentModel (); т.к. DocumentModel больше не наследуется от QAbstractItemModel, а содержит указатель на нее.

RiseOfDeath commented 10 years ago

Ну сейчас, по крайней мере, не ругается ни на что. Осталось по-быстрому все проверить.

И вы правы оказались, это была ветка master. Щас пробую для 3.2 сделать и для 3.1.2.

RiseOfDeath commented 10 years ago

Вроде бы пашет. Хотя есть один критический баг (ради которого отдельный issue делать не хочу):

cppcheck: there is no --enable parameter with the name 'warning'

У меня Cppcheck 1.52

--enable= Enable additional checks. The available ids are: * all Enable all checks * style Enable all coding style checks. All messages with the severities 'style', 'performance' and 'portability' are enabled. * performance Enable performance messages * portability Enable portability messages * information Enable information messages * unusedFunction Check for unused functions * missingInclude Warn if there are missing includes. For detailed information, use '--check-config'. Several ids can be given if you separate them with commas.

Т.е. там нет опции warnin, да и как я понял вы просто все опции сразу пихаете, так что можно их заменить на all.

И, к стати, проверил сам плагин самим плагином:

/home/anton/workspace/qtc-cppcheck/src/OptionsPage.cpp:26: предупреждение: Cppcheck: The function 'matches' is never used

OneMoreGres commented 10 years ago

Рад, что проблемы решились :) --enable=all автоматически включает unusedFunction, которая, в свою очередь, выключает многопоточный анализ. Для этого и сделана отдельная галочка для "неиспользуемых функций". Так что буду искать какое-то другое решение. Насчет старого cppcheck.. Исправлю. Скорее всего сделаю возможность замены, а не дополнения параметра enable из пользовательских параметров в настройках. По поводу matches. У меня cppcheck такого не находит :). А вообще это часть API Creator'а, так что вызовы просто вне зоны видимости плагина. Пулл реквест прокомментирую отдельно.