From a30f47e27fda21023e7de5c4b5bcbb257290cb8b Mon Sep 17 00:00:00 2001 From: Malte Langkabel Date: Fri, 14 Feb 2020 16:34:04 +0100 Subject: [PATCH] build: Treat warnings as errors (#923) * squash and rebase andronov-alexey:treat_warnings_as_errors from pull request #850 * fix remaining warnings in java lib --- CMakeLists.txt | 26 +++++ src/app/main.cpp | 3 + src/lib/app/Application.cpp | 2 +- .../component/controller/CodeController.cpp | 39 ++++---- .../component/controller/ErrorController.cpp | 2 +- .../component/controller/GraphController.cpp | 48 +++++---- .../controller/UndoRedoController.cpp | 2 +- .../controller/helper/ListLayouter.cpp | 12 ++- .../helper/NetworkProtocolHelper.cpp | 2 +- .../controller/helper/TrailLayouter.cpp | 8 +- src/lib/component/view/GraphViewStyle.cpp | 25 +++-- .../view/helper/CodeSnippetParams.cpp | 2 +- src/lib/data/NodeTypeSet.cpp | 2 +- src/lib/data/TaskFinishParsing.cpp | 4 +- .../fulltextsearch/FullTextSearchIndex.cpp | 2 +- src/lib/data/fulltextsearch/SuffixArray.cpp | 8 +- .../TokenComponentAggregation.cpp | 2 +- src/lib/data/indexer/TaskBuildIndex.cpp | 2 +- .../indexer/TaskExecuteCustomCommands.cpp | 9 +- .../shared_types/SharedIndexerCommand.cpp | 7 ++ .../shared_types/SharedIndexerCommand.h | 5 +- .../SharedIntermediateStorage.cpp | 2 +- src/lib/data/location/SourceLocationFile.cpp | 4 +- src/lib/data/parser/TaskParseWrapper.cpp | 2 +- src/lib/data/search/SearchIndex.cpp | 7 +- src/lib/data/storage/IntermediateStorage.cpp | 2 +- src/lib/data/storage/PersistentStorage.cpp | 12 ++- src/lib/data/storage/StorageProvider.cpp | 2 +- .../storage/sqlite/SqliteBookmarkStorage.cpp | 8 +- .../storage/sqlite/SqliteIndexStorage.cpp | 98 ++++++++++--------- src/lib/project/Project.cpp | 9 +- src/lib/settings/ProjectSettings.cpp | 5 + src/lib/settings/Settings.cpp | 2 +- .../SourceGroupSettingsWithComponents.h | 10 +- src/lib/utility/LowMemoryStringMap.h | 6 ++ src/lib/utility/TimeStamp.cpp | 8 +- src/lib/utility/file/FilePath.cpp | 3 + src/lib/utility/file/utilityFile.cpp | 2 +- src/lib/utility/interprocess/SharedMemory.cpp | 1 - src/lib/utility/logging/FileLogger.cpp | 4 + .../logging/LogManagerImplementation.cpp | 7 +- src/lib/utility/math/MatrixDynamicBase.h | 4 +- .../utility/scheduling/TaskGroupParallel.cpp | 2 +- src/lib/utility/text/TextAccess.cpp | 2 +- src/lib/utility/tracing.cpp | 4 +- src/lib/utility/utilityWindows.cpp | 8 +- .../data/parser/cxx/GeneratePCHAction.h | 2 +- .../parser/cxx/SingleFrontendActionFactory.h | 2 +- .../cxx/name_resolver/CxxDeclNameResolver.cpp | 8 +- .../cxx/name_resolver/CxxDeclNameResolver.h | 2 +- .../CxxTemplateParameterStringResolver.cpp | 2 +- .../cxx/name_resolver/CxxTypeNameResolver.cpp | 6 +- src/lib_cxx/data/parser/cxx/utilityClang.cpp | 4 + src/lib_cxx/utility/IncludeProcessing.cpp | 2 +- .../platform_includes/includesWindows.h | 3 + src/lib_gui/qt/element/QtStatusBar.cpp | 2 +- src/lib_gui/qt/element/QtTable.cpp | 7 +- src/lib_gui/qt/element/code/QtCodeArea.cpp | 23 +++-- src/lib_gui/qt/element/code/QtCodeField.cpp | 34 +++---- .../qt/element/code/QtCodeFileList.cpp | 4 +- .../qt/element/code/QtCodeFileSingle.cpp | 4 +- .../qt/element/code/QtCodeFileTitleButton.cpp | 2 +- .../qt/element/code/QtCodeNavigateable.cpp | 10 +- .../qt/element/code/QtCodeNavigator.cpp | 2 +- .../qt/element/dialog/QtProgressBar.cpp | 2 +- .../element/search/QtAutocompletionList.cpp | 70 ++++++++----- .../qt/element/search/QtSearchBarButton.cpp | 10 +- .../qt/element/search/QtSmartSearchBox.cpp | 14 +-- .../qt/graphics/base/QtCountCircleItem.cpp | 10 +- .../qt/graphics/base/QtGraphicsView.cpp | 10 +- .../qt/graphics/base/QtLineItemAngled.cpp | 4 +- .../qt/graphics/base/QtLineItemBase.cpp | 24 ++--- .../QtGraphNodeComponentClickable.cpp | 8 +- .../QtGraphNodeComponentMoveable.cpp | 11 ++- src/lib_gui/qt/graphics/graph/QtGraphEdge.cpp | 10 +- src/lib_gui/qt/graphics/graph/QtGraphNode.cpp | 26 ++--- .../qt/graphics/graph/QtGraphNodeAccess.cpp | 7 +- .../qt/graphics/graph/QtGraphNodeBundle.cpp | 3 +- .../graph/QtGraphNodeExpandToggle.cpp | 7 +- .../qt/graphics/graph/QtGraphNodeGroup.cpp | 7 +- .../graphics/graph/QtGraphNodeQualifier.cpp | 32 +++--- src/lib_gui/qt/network/QtTcpWrapper.cpp | 2 +- .../qt/project_wizard/QtProjectWizard.cpp | 85 ++++++++++------ .../QtProjectWizardContentCStandard.cpp | 2 +- .../QtProjectWizardContentCppStandard.cpp | 2 +- ...ctWizardContentCrossCompilationOptions.cpp | 8 +- .../QtProjectWizardContentPreferences.cpp | 7 +- ...tProjectWizardContentPathsHeaderSearch.cpp | 4 +- .../qt/utility/QtDeviceScaledPixmap.cpp | 6 +- src/lib_gui/qt/utility/QtHighlighter.cpp | 4 +- .../utility/QtScrollSpeedChangeListener.cpp | 2 +- .../qt/utility/QtWindowsTaskbarButton.cpp | 3 +- src/lib_gui/qt/utility/utilityQt.cpp | 26 ++--- src/lib_gui/qt/view/QtErrorView.cpp | 3 +- src/lib_gui/qt/view/QtGraphView.cpp | 19 ++-- src/lib_gui/qt/view/QtGraphViewStyleImpl.cpp | 4 +- src/lib_gui/qt/view/QtTabsView.cpp | 5 +- src/lib_gui/qt/window/QtAbout.cpp | 3 +- src/lib_gui/qt/window/QtIndexingDialog.cpp | 2 +- .../qt/window/QtIndexingProgressDialog.cpp | 4 +- src/lib_gui/qt/window/QtProgressBarDialog.cpp | 15 ++- src/lib_gui/qt/window/QtWindow.cpp | 3 +- .../java_runtime/JavaPathDetectorLinux.cpp | 4 +- src/lib_java/utility/utilityJava.cpp | 7 +- src/lib_utility/utility/utilityString.cpp | 5 +- src/test/CommandlineTestSuite.cpp | 4 +- src/test/MatrixBaseTestSuite.cpp | 7 +- src/test/SharedMemoryTestSuite.cpp | 5 +- src/test/SourceGroupTestSuite.cpp | 2 +- src/test/SqliteBookmarkStorageTestSuite.cpp | 6 +- src/test/SqliteIndexStorageTestSuite.cpp | 12 +-- src/test/Vector2TestSuite.cpp | 3 + 112 files changed, 634 insertions(+), 430 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c48ff3c9..cc5ec013 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,7 @@ set(BUILD_CXX_LANGUAGE_PACKAGE OFF CACHE BOOL "Add C and C++ support to the Sour set(BUILD_JAVA_LANGUAGE_PACKAGE OFF CACHE BOOL "Add Java support to the Sourcetrail indexer.") set(BUILD_PYTHON_LANGUAGE_PACKAGE OFF CACHE BOOL "Add Python support to the Sourcetrail indexer.") set(DOCKER_BUILD OFF CACHE BOOL "Build runs in Docker") +set(TREAT_WARNINGS_AS_ERRORS ON CACHE BOOL "Treat compiler warnings as errors") #set (CMAKE_VERBOSE_MAKEFILE ON) @@ -88,6 +89,31 @@ if (DOCKER_BUILD) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++") endif() +if (TREAT_WARNINGS_AS_ERRORS) + if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + # Visual Studio 2017 version 15.9 <= Version <= Visual Studio 2019 Version 16.4 + if ((MSVC_VERSION GREATER_EQUAL 1916) AND (MSVC_VERSION LESS_EQUAL 1924)) + # Warning 4003: not enough actual parameters for macro 'identifier' + # Warning 4250: 'class1' inherits 'class2::member' via dominance + set(WARNINGS_LIST "/wd4003 /wd4250") + set(CMAKE_CXX_WARNINGS_FLAGS "/experimental:external /external:anglebrackets /external:W0 /WX") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_WARNINGS_FLAGS} ${WARNINGS_LIST}") + + # Treat linker warnings as errors + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /WX") + set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /WX") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /WX") + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /WX") + + message(STATUS "'Treat warnings as errors' policy is enabled") + else() + message(STATUS "'Treat warnings as errors' policy is disabled") + endif() + else() + message(STATUS "'Treat warnings as errors' policy is disabled") + endif() +endif() + # For debugging the release build on linux #if (UNIX AND "${CMAKE_BUILD_TYPE}" STREQUAL "Release") #add_definitions(-fno-omit-frame-pointer) diff --git a/src/app/main.cpp b/src/app/main.cpp index c1e72a10..4e75ad12 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -95,10 +95,13 @@ int main(int argc, char *argv[]) { QCoreApplication::addLibraryPath(QStringLiteral(".")); +#pragma warning(push) +#pragma warning(disable : 4996) if (utility::getOsType() == OS_LINUX && std::getenv("SOURCETRAIL_VIA_SCRIPT") == nullptr) { std::cout << "ERROR: Please run Sourcetrail via the Sourcetrail.sh script!" << std::endl; } +#pragma warning(pop) QApplication::setApplicationName(QStringLiteral("Sourcetrail")); diff --git a/src/lib/app/Application.cpp b/src/lib/app/Application.cpp index 93355ffd..0498544c 100644 --- a/src/lib/app/Application.cpp +++ b/src/lib/app/Application.cpp @@ -450,7 +450,7 @@ void Application::updateRecentProjects(const FilePath& projectSettingsFilePath) } recentProjects.insert(recentProjects.begin(), projectSettingsFilePath); - while (recentProjects.size() > appSettings->getMaxRecentProjectsCount()) + while (static_cast(recentProjects.size()) > appSettings->getMaxRecentProjectsCount()) { recentProjects.pop_back(); } diff --git a/src/lib/component/controller/CodeController.cpp b/src/lib/component/controller/CodeController.cpp index b4235c4b..cfe5ef35 100644 --- a/src/lib/component/controller/CodeController.cpp +++ b/src/lib/component/controller/CodeController.cpp @@ -381,7 +381,9 @@ void CodeController::handleMessage(MessageCodeShowDefinition* message) if (message->inIDE) { - MessageMoveIDECursor(filePath, lineNumber, columnNumber).dispatch(); + MessageMoveIDECursor( + filePath, static_cast(lineNumber), static_cast(columnNumber)) + .dispatch(); return; } @@ -471,10 +473,10 @@ void CodeController::handleMessage(MessageShowError* message) void CodeController::handleMessage(MessageShowReference* message) { - m_referenceIndex = message->refIndex; + m_referenceIndex = static_cast(message->refIndex); bool replayed = message->isReplayed(); - if (m_referenceIndex >= 0 && m_referenceIndex < m_references.size()) + if (m_referenceIndex >= 0 && m_referenceIndex < static_cast(m_references.size())) { const Reference& ref = m_references[m_referenceIndex]; m_codeParams.activeLocationIds = {ref.locationId}; @@ -641,7 +643,7 @@ std::vector CodeController::getSnippetsForFile( activeSourceLocations->getFilePath(), showsErrors); size_t lineCount = textAccess->getLineCount(); - SnippetMerger fileScopedMerger(1, lineCount); + SnippetMerger fileScopedMerger(1, static_cast(lineCount)); std::map> mergers; std::shared_ptr scopeLocations = @@ -657,8 +659,9 @@ std::vector CodeController::getSnippetsForFile( activeSourceLocations->getFilePath(), LOCATION_COMMENT); commentLocations->forEachStartSourceLocation([&](SourceLocation* location) { atomicRanges.push_back(SnippetMerger::Range( - SnippetMerger::Border(location->getLineNumber(), false), - SnippetMerger::Border(location->getOtherLocation()->getLineNumber(), false))); + SnippetMerger::Border(static_cast(location->getLineNumber()), false), + SnippetMerger::Border( + static_cast(location->getOtherLocation()->getLineNumber()), false))); }); atomicRanges = SnippetMerger::Range::mergeAdjacent(atomicRanges); @@ -673,7 +676,7 @@ std::vector CodeController::getSnippetsForFile( params.startLineNumber = std::max( 1, range.start.row - (range.start.strong ? 0 : snippetExpandRange)); params.endLineNumber = std::min( - lineCount, range.end.row + (range.end.strong ? 0 : snippetExpandRange)); + static_cast(lineCount), range.end.row + (range.end.strong ? 0 : snippetExpandRange)); params.locationFile = activeSourceLocations->getFilteredByLines( params.startLineNumber, params.endLineNumber); @@ -712,8 +715,9 @@ std::vector CodeController::getSnippetsForFile( params.footer = activeSourceLocations->getFilePath().wstr(); } - for (const std::string& line: - textAccess->getLines(params.startLineNumber, params.endLineNumber)) + for (const std::string& line: textAccess->getLines( + static_cast(params.startLineNumber), + static_cast(params.endLineNumber))) { params.code += line; } @@ -731,7 +735,8 @@ std::shared_ptr CodeController::buildMergerHierarchy( std::map>& mergers) const { std::shared_ptr currentMerger = std::make_shared( - location->getStartLocation()->getLineNumber(), location->getEndLocation()->getLineNumber()); + static_cast(location->getStartLocation()->getLineNumber()), + static_cast(location->getEndLocation()->getLineNumber())); const SourceLocation* scopeLocation = getSourceLocationOfParentScope( location->getLineNumber(), scopeLocations); @@ -743,11 +748,11 @@ std::shared_ptr CodeController::buildMergerHierarchy( std::shared_ptr nextMerger; std::map>::iterator it = mergers.find( - scopeLocation->getLocationId()); + static_cast(scopeLocation->getLocationId())); if (it == mergers.end()) { nextMerger = buildMergerHierarchy(scopeLocation, scopeLocations, fileScopedMerger, mergers); - mergers[scopeLocation->getLocationId()] = nextMerger; + mergers[static_cast(scopeLocation->getLocationId())] = nextMerger; } else { @@ -986,7 +991,7 @@ void CodeController::iterateReference(bool next) { if (m_referenceIndex < 1) { - m_referenceIndex = m_references.size() - 1; + m_referenceIndex = static_cast(m_references.size()) - 1; } else { @@ -1009,7 +1014,7 @@ void CodeController::iterateLocalReference(bool next, bool updateView) { m_localReferenceIndex++; - if (m_localReferenceIndex == m_localReferences.size()) + if (m_localReferenceIndex == static_cast(m_localReferences.size())) { m_localReferenceIndex = 0; } @@ -1018,7 +1023,7 @@ void CodeController::iterateLocalReference(bool next, bool updateView) { if (m_localReferenceIndex < 1) { - m_localReferenceIndex = m_localReferences.size() - 1; + m_localReferenceIndex = static_cast(m_localReferences.size()) - 1; } else { @@ -1036,7 +1041,7 @@ void CodeController::iterateLocalReference(bool next, bool updateView) { if (m_references[i].locationId == ref.locationId) { - m_referenceIndex = i; + m_referenceIndex = static_cast(i); } } } @@ -1382,7 +1387,7 @@ void CodeController::showFirstActiveReference(Id tokenId, bool updateView) if (!firstReference.tokenId) { firstReference = ref; - referenceIndex = i; + referenceIndex = static_cast(i); } } diff --git a/src/lib/component/controller/ErrorController.cpp b/src/lib/component/controller/ErrorController.cpp index a07abe62..d93e259f 100644 --- a/src/lib/component/controller/ErrorController.cpp +++ b/src/lib/component/controller/ErrorController.cpp @@ -73,7 +73,7 @@ void ErrorController::handleMessage(MessageErrorCountUpdate* message) ErrorFilter filter = getView()->getErrorFilter(); - int room = filter.limit - m_errorCount; + int room = static_cast(filter.limit) - static_cast(m_errorCount); if (room > 0) { filter.limit = 0; diff --git a/src/lib/component/controller/GraphController.cpp b/src/lib/component/controller/GraphController.cpp index 9ca1804c..c448a7d9 100644 --- a/src/lib/component/controller/GraphController.cpp +++ b/src/lib/component/controller/GraphController.cpp @@ -1269,7 +1269,7 @@ void GraphController::bundleNodesAndEdgesMatching( bundleNode->name = name; bundleNode->visible = true; - for (int i = matchedNodeIndices.size() - 1; i >= 0; i--) + for (int i = static_cast(matchedNodeIndices.size()) - 1; i >= 0; i--) { std::shared_ptr node = m_dummyNodes[matchedNodeIndices[i]]; node->visible = false; @@ -1366,7 +1366,7 @@ std::shared_ptr GraphController::bundleNodesMatching( bundleNode->name = name; bundleNode->visible = true; - for (int i = matchedNodes.size() - 1; i >= 0; i--) + for (int i = static_cast(matchedNodes.size()) - 1; i >= 0; i--) { std::shared_ptr node = *matchedNodes[i]; node->visible = false; @@ -1484,7 +1484,7 @@ void GraphController::addCharacterIndex() m_dummyNodes.insert(m_dummyNodes.end(), newNodes.begin(), newNodes.end()); // Add index characters - char character = 0; + wchar_t character = 0; for (size_t i = 0; i < m_dummyNodes.size(); i++) { if (!m_dummyNodes[i]->visible || !m_dummyNodes[i]->name.size()) @@ -1950,7 +1950,7 @@ Vec4i GraphController::layoutNestingRecursive(DummyNode* node, int relayoutAcces if (node->isGraphNode()) { node->name = utility::elide(node->name, utility::ELIDE_RIGHT, node->active ? 100 : 50); - width = margins.charWidth * node->name.size(); + width = static_cast(margins.charWidth * node->name.size()); if (node->data->getType().isCollapsible() && node->data->getChildCount() > 0) { @@ -1959,11 +1959,11 @@ Vec4i GraphController::layoutNestingRecursive(DummyNode* node, int relayoutAcces } else if (node->isBundleNode() || node->isTextNode()) { - width = margins.charWidth * node->name.size(); + width = static_cast(margins.charWidth * node->name.size()); } else if (node->isGroupNode()) { - width = margins.charWidth * node->name.size() + 5; + width = static_cast(margins.charWidth * node->name.size() + 5); } width += margins.iconWidth; @@ -1982,7 +1982,7 @@ Vec4i GraphController::layoutNestingRecursive(DummyNode* node, int relayoutAcces } else if (subNode->isQualifierNode()) { - subNode->position.y = margins.top + margins.charHeight / 2; + subNode->position.y = static_cast(margins.top + margins.charHeight / 2); width += 5; continue; } @@ -2027,7 +2027,10 @@ Vec4i GraphController::layoutNestingRecursive(DummyNode* node, int relayoutAcces case GroupLayout::SKEWED: ListLayouter::layoutSkewed( - &node->subNodes, margins.spacingX, margins.spacingY, viewSize.x() * 1.5); + &node->subNodes, + margins.spacingX, + margins.spacingY, + static_cast(viewSize.x() * 1.5)); break; case GroupLayout::BUCKET: @@ -2060,13 +2063,16 @@ Vec4i GraphController::layoutNestingRecursive(DummyNode* node, int relayoutAcces } Vec2i size = ListLayouter::offsetNodes( - node->subNodes, margins.top + margins.charHeight + margins.spacingA, margins.left); + node->subNodes, + static_cast(margins.top + margins.charHeight + margins.spacingA), + margins.left); width = std::max(size.x(), width); height = size.y(); node->size.x = margins.left + width + margins.right; - node->size.y = margins.top + margins.charHeight + margins.spacingA + height + margins.bottom; + node->size.y = static_cast( + margins.top + margins.charHeight + margins.spacingA + height + margins.bottom); for (const std::shared_ptr& subNode: node->subNodes) { @@ -2158,7 +2164,7 @@ void GraphController::layoutToGrid(DummyNode* node) const if (subNode->isAccessNode()) { - subNode->size.x = subNode->size.x + incX; + subNode->size.x = static_cast(subNode->size.x + incX); lastAccessNode = subNode.get(); } else if (subNode->isExpandToggleNode()) @@ -2169,15 +2175,15 @@ void GraphController::layoutToGrid(DummyNode* node) const if (lastAccessNode) { - lastAccessNode->size.y = lastAccessNode->size.y + incY; + lastAccessNode->size.y = static_cast(lastAccessNode->size.y + incY); if (expandToggleNode) { - expandToggleNode->position.x = expandToggleNode->position.x + incX; + expandToggleNode->position.x = static_cast(expandToggleNode->position.x + incX); } - node->size.x = width; - node->size.y = height; + node->size.x = static_cast(width); + node->size.y = static_cast(height); } } @@ -2409,8 +2415,8 @@ void GraphController::createLegendGraph() addText(L"Legend", 6, Vec2i(0, 0)); - size_t y = 50; - size_t x = 0; + int y = 50; + int x = 0; // Layout { @@ -2474,12 +2480,12 @@ void GraphController::createLegendGraph() x = 0; y = 610; - size_t dx = 200; - size_t dy = 50; + int dx = 200; + int dy = 50; // Nodes { - size_t i = 0; + int i = 0; addText(L"Nodes", 3, Vec2i(x, y)); addNode(NodeType::NODE_FILE, L"File", Vec2i(x, y + dy * ++i)); @@ -2581,7 +2587,7 @@ void GraphController::createLegendGraph() // Edges { addText(L"Edges", 3, Vec2i(x, y)); - size_t i = 0; + int i = 0; { addText(L"file include", 0, Vec2i(x, y + dy * ++i)); diff --git a/src/lib/component/controller/UndoRedoController.cpp b/src/lib/component/controller/UndoRedoController.cpp index 93c60905..bb5ff4b1 100644 --- a/src/lib/component/controller/UndoRedoController.cpp +++ b/src/lib/component/controller/UndoRedoController.cpp @@ -628,7 +628,7 @@ void UndoRedoController::updateHistory() const size_t historyListSize = 50; std::vector historyListMatches; - size_t index = 0; + int index = 0; int currentIndex = -1; m_historyOffset = 0; diff --git a/src/lib/component/controller/helper/ListLayouter.cpp b/src/lib/component/controller/helper/ListLayouter.cpp index 9cb7c930..d30cd2d3 100644 --- a/src/lib/component/controller/helper/ListLayouter.cpp +++ b/src/lib/component/controller/helper/ListLayouter.cpp @@ -36,8 +36,9 @@ void ListLayouter::layoutMultiColumn(Vec2i viewSize, std::vector maxWidths = std::vector(cols, 0); size_t nodesPerCol = - (cols == 1 ? visibleNodes.size() - : std::ceil((visibleNodes.size() + cols - 1) / double(cols))); + (cols == 1 + ? visibleNodes.size() + : static_cast(std::ceil((visibleNodes.size() + cols - 1) / double(cols)))); int maxHeight = 0; int height = -gapY; @@ -86,7 +87,8 @@ void ListLayouter::layoutMultiColumn(Vec2i viewSize, std::vector( + std::ceil((visibleNodes.size() + colsFinal - 1) / double(colsFinal)))); std::shared_ptr lastTextNode; for (size_t i = 0; i < visibleNodes.size(); i++) @@ -151,9 +153,9 @@ void ListLayouter::layoutSquare(std::vector>* nodes, } int diff = -1; - size_t cols = 1; + int cols = 1; - for (size_t i = cols; i < 100; i++) + for (int i = cols; i < 100; i++) { if (layoutSquareInternal( visibleNodes, Vec2i(maxWidth, totalHeight * i / 100), Vec2i(gapX, gapY))) diff --git a/src/lib/component/controller/helper/NetworkProtocolHelper.cpp b/src/lib/component/controller/helper/NetworkProtocolHelper.cpp index 0109f281..db10ff75 100644 --- a/src/lib/component/controller/helper/NetworkProtocolHelper.cpp +++ b/src/lib/component/controller/helper/NetworkProtocolHelper.cpp @@ -134,7 +134,7 @@ NetworkProtocolHelper::CreateCDBProjectMessage NetworkProtocolHelper::parseCreat } else { - const int subMessageCount = subMessages.size(); + const size_t subMessageCount = subMessages.size(); const std::wstring cdbPath = subMessages[1]; if (!cdbPath.empty()) diff --git a/src/lib/component/controller/helper/TrailLayouter.cpp b/src/lib/component/controller/helper/TrailLayouter.cpp index 83953fb2..3e8e2dfd 100644 --- a/src/lib/component/controller/helper/TrailLayouter.cpp +++ b/src/lib/component/controller/helper/TrailLayouter.cpp @@ -309,8 +309,8 @@ void TrailLayouter::buildColumns() { for (const std::shared_ptr& node: m_allNodes) { - int level = node->level + 1; - for (int i = m_nodesPerCol.size(); i <= level; i++) + const int level = node->level + 1; + for (int i = static_cast(m_nodesPerCol.size()); i <= level; i++) { m_nodesPerCol.push_back(std::vector()); } @@ -365,7 +365,7 @@ void TrailLayouter::reduceEdgeCrossings() } } - float value = j; + float value = float(j); if (count) { value = float(sum) / count; @@ -508,7 +508,7 @@ void TrailLayouter::moveNodesToAveragePosition(std::vector nodes, bo { averagePosition += p.first; } - averagePosition /= averagePositions.size(); + averagePosition /= static_cast(averagePositions.size()); std::multimap distanceFromAveragePosition; diff --git a/src/lib/component/view/GraphViewStyle.cpp b/src/lib/component/view/GraphViewStyle.cpp index 93f406b6..aeb48ac7 100644 --- a/src/lib/component/view/GraphViewStyle.cpp +++ b/src/lib/component/view/GraphViewStyle.cpp @@ -145,7 +145,7 @@ void GraphViewStyle::loadStyleSettings() s_edgeColors.clear(); s_screenMatchColors.clear(); - s_gridCellPadding = getCharHeight(NodeType::STYLE_BIG_NODE) - 8; + s_gridCellPadding = static_cast(getCharHeight(NodeType::STYLE_BIG_NODE) - 8); s_gridCellSize = s_gridCellPadding / 2; } @@ -316,7 +316,8 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsOfExpandToggleNode() NodeMargins margins; margins.left = margins.right = margins.top = margins.bottom = 6; - margins.minWidth = margins.charHeight = getFontSizeOfExpandToggleNode(); + margins.charHeight = static_cast(getFontSizeOfExpandToggleNode()); + margins.minWidth = static_cast(margins.charHeight); return margins; } @@ -332,7 +333,8 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsOfTextNode(int fontSizeDif margins.left = margins.right = 0; margins.top = margins.bottom = 6; - margins.minWidth = margins.charHeight = getFontSizeOfTextNode(fontSizeDiff); + margins.charHeight = static_cast(getFontSizeOfTextNode(fontSizeDiff)); + margins.minWidth = static_cast(margins.charHeight); margins.charWidth = getCharWidth(getFontNameOfTextNode(), getFontSizeOfTextNode(fontSizeDiff)); @@ -357,7 +359,8 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsOfGroupNode(GroupType type if (hasName) { - margins.minWidth = margins.charHeight = getFontSizeOfGroupNode(); + margins.charHeight = static_cast(getFontSizeOfGroupNode()); + margins.minWidth = static_cast(margins.charHeight); } margins.charWidth = getCharWidth(NodeType::STYLE_GROUP); @@ -618,7 +621,7 @@ GraphViewStyle::EdgeStyle GraphViewStyle::getStyleForEdgeType( { EdgeStyle style; - style.width = isActive ? 4 : 2; + style.width = isActive ? 4.0f : 2.0f; style.zValue = isActive ? 5 : 2; if (isTrailEdge) @@ -688,7 +691,7 @@ GraphViewStyle::EdgeStyle GraphViewStyle::getStyleForEdgeType( style.verticalOffset = 0; style.cornerRadius = 7; style.zValue = isActive ? 2 : -3; - style.width = isActive ? 3 : 2; + style.width = isActive ? 3.0f : 2.0f; if (isTrailEdge) { @@ -725,13 +728,15 @@ int GraphViewStyle::toGridOffset(int x) { if (x > 0) { - return std::ceil(x / double(s_gridCellPadding + s_gridCellSize)) * - (s_gridCellPadding + s_gridCellSize); + return static_cast( + std::ceil(x / double(s_gridCellPadding + s_gridCellSize)) * + (s_gridCellPadding + s_gridCellSize)); } else { - return std::floor(x / double(s_gridCellPadding + s_gridCellSize)) * - (s_gridCellPadding + s_gridCellSize); + return static_cast( + std::floor(x / double(s_gridCellPadding + s_gridCellSize)) * + (s_gridCellPadding + s_gridCellSize)); } } diff --git a/src/lib/component/view/helper/CodeSnippetParams.cpp b/src/lib/component/view/helper/CodeSnippetParams.cpp index 62dd44a8..b18c6340 100644 --- a/src/lib/component/view/helper/CodeSnippetParams.cpp +++ b/src/lib/component/view/helper/CodeSnippetParams.cpp @@ -26,7 +26,7 @@ CodeSnippetParams CodeSnippetParams::merge(const CodeSnippetParams& a, const Cod std::string code = first->code; std::string secondCode = second->code; - int secondCodeStartIndex = 0; + size_t secondCodeStartIndex = 0; for (size_t i = second->startLineNumber; i <= first->endLineNumber; i++) { secondCodeStartIndex = secondCode.find("\n", secondCodeStartIndex) + 1; diff --git a/src/lib/data/NodeTypeSet.cpp b/src/lib/data/NodeTypeSet.cpp index 2855d844..cd9e9754 100644 --- a/src/lib/data/NodeTypeSet.cpp +++ b/src/lib/data/NodeTypeSet.cpp @@ -162,7 +162,7 @@ NodeTypeSet::NodeTypeSet(NodeTypeSet::MaskType typeMask): m_nodeTypeMask(typeMas NodeTypeSet::MaskType NodeTypeSet::nodeTypeToMask(const NodeType& nodeType) { // todo: convert to mask if ids are not power of two anymore - return nodeType.getId(); + return static_cast(nodeType.getId()); } const std::vector NodeTypeSet::s_allNodeTypes = { diff --git a/src/lib/data/TaskFinishParsing.cpp b/src/lib/data/TaskFinishParsing.cpp index 982a4c1b..02e54286 100644 --- a/src/lib/data/TaskFinishParsing.cpp +++ b/src/lib/data/TaskFinishParsing.cpp @@ -36,7 +36,7 @@ Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr blackboa m_storage->optimizeMemory(); m_dialogView->hideUnknownProgressDialog(); - float time = TimeStamp::durationSeconds(start); + double time = TimeStamp::durationSeconds(start); if (blackboard->exists("clear_time")) { @@ -85,7 +85,7 @@ Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr blackboa sourceFileCount, stats.completedFileCount, stats.fileCount, - time, + static_cast(time), errorInfo, interruptedIndexing, shallowIndexing); diff --git a/src/lib/data/fulltextsearch/FullTextSearchIndex.cpp b/src/lib/data/fulltextsearch/FullTextSearchIndex.cpp index 50e82cf3..d2b5426d 100644 --- a/src/lib/data/fulltextsearch/FullTextSearchIndex.cpp +++ b/src/lib/data/fulltextsearch/FullTextSearchIndex.cpp @@ -11,7 +11,7 @@ void FullTextSearchIndex::addFile(Id fileId, const std::wstring& fileContent) LOG_ERROR("empty file not added to fulltextsearch index"); } - if (fileContent.size() >= std::numeric_limits::max()) + if (static_cast(fileContent.size()) >= std::numeric_limits::max()) { LOG_ERROR("file too big not added to fulltextsearch index"); } diff --git a/src/lib/data/fulltextsearch/SuffixArray.cpp b/src/lib/data/fulltextsearch/SuffixArray.cpp index 980b5bbf..9f3cffc3 100644 --- a/src/lib/data/fulltextsearch/SuffixArray.cpp +++ b/src/lib/data/fulltextsearch/SuffixArray.cpp @@ -46,7 +46,7 @@ void SuffixArray::printLCP() const std::vector SuffixArray::buildLCP() { - const int n = m_array.size(); + const int n = static_cast(m_array.size()); std::vector lcp(n, 0); std::vector invSuff(n, 0); @@ -89,8 +89,8 @@ std::vector SuffixArray::searchForTerm(const std::wstring& searchTerm) cons std::wstring term = searchTerm; std::transform(term.begin(), term.end(), term.begin(), ::towlower); - const int termLength = term.length(); - const int textLength = m_text.length(); + const int termLength = static_cast(term.length()); + const int textLength = static_cast(m_text.length()); int l = -1; int r = textLength; int m; @@ -131,7 +131,7 @@ std::vector SuffixArray::searchForTerm(const std::wstring& searchTerm) cons std::vector SuffixArray::buildSuffixArray() { - const int n = m_text.length(); + const int n = static_cast(m_text.length()); std::vector suffixes; suffixes.reserve(n); diff --git a/src/lib/data/graph/token_component/TokenComponentAggregation.cpp b/src/lib/data/graph/token_component/TokenComponentAggregation.cpp index aa55a84a..ebd16e3b 100644 --- a/src/lib/data/graph/token_component/TokenComponentAggregation.cpp +++ b/src/lib/data/graph/token_component/TokenComponentAggregation.cpp @@ -25,7 +25,7 @@ std::shared_ptr TokenComponentAggregation::copy() const int TokenComponentAggregation::getAggregationCount() const { - return m_ids.size(); + return static_cast(m_ids.size()); } std::set TokenComponentAggregation::getAggregationIds() const diff --git a/src/lib/data/indexer/TaskBuildIndex.cpp b/src/lib/data/indexer/TaskBuildIndex.cpp index e0c2a134..c6ef090b 100644 --- a/src/lib/data/indexer/TaskBuildIndex.cpp +++ b/src/lib/data/indexer/TaskBuildIndex.cpp @@ -268,7 +268,7 @@ bool TaskBuildIndex::fetchIntermediateStorages(std::shared_ptr black std::shared_ptr storageManager = m_interprocessIntermediateStorageManagers[finishedProcessId - 1]; - int storageCount = storageManager->getIntermediateStorageCount(); + const size_t storageCount = storageManager->getIntermediateStorageCount(); if (!storageCount) { break; diff --git a/src/lib/data/indexer/TaskExecuteCustomCommands.cpp b/src/lib/data/indexer/TaskExecuteCustomCommands.cpp index 1e42d66e..a252f818 100644 --- a/src/lib/data/indexer/TaskExecuteCustomCommands.cpp +++ b/src/lib/data/indexer/TaskExecuteCustomCommands.cpp @@ -89,7 +89,10 @@ Task::TaskState TaskExecuteCustomCommands::doUpdate(std::shared_ptr for (size_t i = 1 /*this method is counting as the first thread*/; i < m_indexerThreadCount; i++) { indexerThreads.push_back(std::make_shared( - &TaskExecuteCustomCommands::executeParallelIndexerCommands, this, i, blackboard)); + &TaskExecuteCustomCommands::executeParallelIndexerCommands, + this, + static_cast(i), + blackboard)); } while (!m_interrupted && !m_serialCommands.empty()) @@ -138,7 +141,7 @@ Task::TaskState TaskExecuteCustomCommands::doUpdate(std::shared_ptr void TaskExecuteCustomCommands::doExit(std::shared_ptr blackboard) { m_storage.reset(); - const float duration = TimeStamp::durationSeconds(m_start); + const float duration = static_cast(TimeStamp::durationSeconds(m_start)); blackboard->update( "index_time", [duration](float currentDuration) { return currentDuration + duration; }); } @@ -336,7 +339,7 @@ void TaskExecuteCustomCommands::runPythonPostProcessing(PersistentStorage& stora } const std::wstring token = utility::decodeFromUtf8( - textAccess->getLine(startLoc->getLineNumber()) + textAccess->getLine(static_cast(startLoc->getLineNumber())) .substr( startLoc->getColumnNumber() - 1, endLoc->getColumnNumber() - startLoc->getColumnNumber() + 1)); diff --git a/src/lib/data/indexer/interprocess/shared_types/SharedIndexerCommand.cpp b/src/lib/data/indexer/interprocess/shared_types/SharedIndexerCommand.cpp index e1695c89..094b9094 100644 --- a/src/lib/data/indexer/interprocess/shared_types/SharedIndexerCommand.cpp +++ b/src/lib/data/indexer/interprocess/shared_types/SharedIndexerCommand.cpp @@ -64,6 +64,13 @@ std::shared_ptr SharedIndexerCommand::fromShared(const SharedInd indexerCommand.getLanguageStandard(), indexerCommand.getClassPaths()); #endif // BUILD_JAVA_LANGUAGE_PACKAGE +#if BUILD_PYTHON_LANGUAGE_PACKAGE + case PYTHON: + LOG_ERROR( + L"Cannot convert shared IndexerCommand for file: " + + indexerCommand.getSourceFilePath().wstr() + L". The type is unknown."); + break; +#endif // BUILD_PYTHON_LANGUAGE_PACKAGE default: LOG_ERROR( L"Cannot convert shared IndexerCommand for file: " + diff --git a/src/lib/data/indexer/interprocess/shared_types/SharedIndexerCommand.h b/src/lib/data/indexer/interprocess/shared_types/SharedIndexerCommand.h index 76b296fe..429638ec 100644 --- a/src/lib/data/indexer/interprocess/shared_types/SharedIndexerCommand.h +++ b/src/lib/data/indexer/interprocess/shared_types/SharedIndexerCommand.h @@ -59,8 +59,11 @@ private: CXX, #endif // BUILD_CXX_LANGUAGE_PACKAGE #if BUILD_JAVA_LANGUAGE_PACKAGE - JAVA + JAVA, #endif // BUILD_JAVA_LANGUAGE_PACKAGE +#if BUILD_PYTHON_LANGUAGE_PACKAGE + PYTHON, +#endif // BUILD_PYTHON_LANGUAGE_PACKAGE }; Type getType() const; diff --git a/src/lib/data/indexer/interprocess/shared_types/SharedIntermediateStorage.cpp b/src/lib/data/indexer/interprocess/shared_types/SharedIntermediateStorage.cpp index 36c1e5d9..927a8a1a 100644 --- a/src/lib/data/indexer/interprocess/shared_types/SharedIntermediateStorage.cpp +++ b/src/lib/data/indexer/interprocess/shared_types/SharedIntermediateStorage.cpp @@ -230,5 +230,5 @@ Id SharedIntermediateStorage::getNextId() const void SharedIntermediateStorage::setNextId(const Id nextId) { - m_nextId = nextId; + m_nextId = static_cast(nextId); } diff --git a/src/lib/data/location/SourceLocationFile.cpp b/src/lib/data/location/SourceLocationFile.cpp index 7d1d1632..a989fc74 100644 --- a/src/lib/data/location/SourceLocationFile.cpp +++ b/src/lib/data/location/SourceLocationFile.cpp @@ -229,7 +229,7 @@ std::shared_ptr SourceLocationFile::getFilteredByTypes( size_t typeMask = 0; for (LocationType type: types) { - typeMask |= 1 << type; + typeMask |= static_cast(1) << type; } std::shared_ptr ret = std::make_shared( @@ -237,7 +237,7 @@ std::shared_ptr SourceLocationFile::getFilteredByTypes( for (const std::shared_ptr& location: m_locations) { - if ((1 << location->getType()) & typeMask) + if ((static_cast(1) << location->getType()) & typeMask) { ret->addSourceLocationCopy(location.get()); } diff --git a/src/lib/data/parser/TaskParseWrapper.cpp b/src/lib/data/parser/TaskParseWrapper.cpp index 7f433b24..dad6b0c7 100644 --- a/src/lib/data/parser/TaskParseWrapper.cpp +++ b/src/lib/data/parser/TaskParseWrapper.cpp @@ -36,7 +36,7 @@ Task::TaskState TaskParseWrapper::doUpdate(std::shared_ptr blackboar void TaskParseWrapper::doExit(std::shared_ptr blackboard) { - float duration = TimeStamp::durationSeconds(m_start); + float duration = static_cast(TimeStamp::durationSeconds(m_start)); blackboard->update( "index_time", [duration](float currentDuration) { return currentDuration + duration; }); } diff --git a/src/lib/data/search/SearchIndex.cpp b/src/lib/data/search/SearchIndex.cpp index f46f6c2f..ae20c8b2 100644 --- a/src/lib/data/search/SearchIndex.cpp +++ b/src/lib/data/search/SearchIndex.cpp @@ -439,12 +439,13 @@ int SearchIndex::scoreText(const std::wstring& text, const std::vector& int noLetterScore = 0; int firstLetterScore = 0; - for (size_t i = 0; i < indices.size(); i++) + for (int i = 0; i < static_cast(indices.size()); i++) { // unmatched and consecutive if (i > 0) { - unmatchedLetterScore += (indices[i] - indices[i - 1] - 1) * unmatchedLetterBonus; + unmatchedLetterScore += static_cast( + (indices[i] - indices[i - 1] - 1) * unmatchedLetterBonus); consecutiveLetterScore += (indices[i] - indices[i - 1] == 1) ? consecutiveLetterBonus : 0; } @@ -497,7 +498,7 @@ SearchResult SearchIndex::rescoreText( std::vector textIndices; // match is already within text - int newIdx = indices[0] - (fulltext.size() - text.size()); + const int newIdx = static_cast(indices[0] - (fulltext.size() - text.size())); if (newIdx >= 0) { for (size_t idx: indices) diff --git a/src/lib/data/storage/IntermediateStorage.cpp b/src/lib/data/storage/IntermediateStorage.cpp index 48ba2f0d..31fd72aa 100644 --- a/src/lib/data/storage/IntermediateStorage.cpp +++ b/src/lib/data/storage/IntermediateStorage.cpp @@ -33,7 +33,7 @@ void IntermediateStorage::clear() size_t IntermediateStorage::getByteSize(size_t stringSize) const { - unsigned int byteSize = 0; + size_t byteSize = 0; for (const StorageFile& storageFile: getStorageFiles()) { diff --git a/src/lib/data/storage/PersistentStorage.cpp b/src/lib/data/storage/PersistentStorage.cpp index 710354af..8a7027e0 100644 --- a/src/lib/data/storage/PersistentStorage.cpp +++ b/src/lib/data/storage/PersistentStorage.cpp @@ -625,7 +625,7 @@ std::shared_ptr PersistentStorage::getFullTextSearchLo /*no ref here!*/ fileResults, &collection, &collectionMutex]() { - const int termLength = searchTerm.length(); + const int termLength = static_cast(searchTerm.length()); for (const FullTextSearchResult& fileResult: fileResults) { const FilePath filePath = getFileNodePath(fileResult.fileId); @@ -639,7 +639,7 @@ std::shared_ptr PersistentStorage::getFullTextSearchLo { while (charsTotal + (int)line.length() <= pos) { - charsTotal += line.length(); + charsTotal += static_cast(line.length()); lineNumber++; line = codec.decode(fileContent->getLine(lineNumber)); } @@ -655,7 +655,7 @@ std::shared_ptr PersistentStorage::getFullTextSearchLo } while ((charsTotal + (int)line.length()) < pos + termLength) { - charsTotal += line.length(); + charsTotal += static_cast(line.length()); lineNumber++; line = codec.decode(fileContent->getLine(lineNumber)); } @@ -709,7 +709,7 @@ std::vector PersistentStorage::getAutocompletionMatches( TRACE(); // search in indices - const size_t maxResultsCount = std::pow(3, query.size() + 3); + const size_t maxResultsCount = static_cast(std::pow(3, query.size() + 3)); const size_t maxBestScoredResultsLength = 100; const size_t maxMatchesReturned = 1000; @@ -2280,7 +2280,9 @@ TooltipSnippet PersistentStorage::getTooltipSnippetForNode(const StorageNode& no std::vector annotations; std::vector lines = getFileContent(sigLoc->getFilePath(), false) - ->getLines(sigLoc->getLineNumber(), sigLoc->getEndLocation()->getLineNumber()); + ->getLines( + static_cast(sigLoc->getLineNumber()), + static_cast(sigLoc->getEndLocation()->getLineNumber())); // check if signature location refers to correct locations in the code // wrongly recorded signature locations of implicit template methods in C++ caused crashes diff --git a/src/lib/data/storage/StorageProvider.cpp b/src/lib/data/storage/StorageProvider.cpp index 3757676b..1357d13b 100644 --- a/src/lib/data/storage/StorageProvider.cpp +++ b/src/lib/data/storage/StorageProvider.cpp @@ -5,7 +5,7 @@ int StorageProvider::getStorageCount() const { std::lock_guard lock(m_storagesMutex); - return m_storages.size(); + return static_cast(m_storages.size()); } void StorageProvider::clear() diff --git a/src/lib/data/storage/sqlite/SqliteBookmarkStorage.cpp b/src/lib/data/storage/sqlite/SqliteBookmarkStorage.cpp index dc281f53..dc3e38ba 100644 --- a/src/lib/data/storage/sqlite/SqliteBookmarkStorage.cpp +++ b/src/lib/data/storage/sqlite/SqliteBookmarkStorage.cpp @@ -75,7 +75,7 @@ StorageBookmarkCategory SqliteBookmarkStorage::addBookmarkCategory(const Storage stmt.bind(1, utility::encodeToUtf8(data.name).c_str()); executeStatement(stmt); - return StorageBookmarkCategory(m_database.lastRowId(), data); + return StorageBookmarkCategory(static_cast(m_database.lastRowId()), data); } StorageBookmark SqliteBookmarkStorage::addBookmark(const StorageBookmarkData& data) @@ -93,7 +93,7 @@ StorageBookmark SqliteBookmarkStorage::addBookmark(const StorageBookmarkData& da stmt.bind(3, data.timestamp.c_str()); executeStatement(stmt); - return StorageBookmark(m_database.lastRowId(), data); + return StorageBookmark(static_cast(m_database.lastRowId()), data); } catch (CppSQLite3Exception e) { @@ -107,7 +107,7 @@ StorageBookmarkedNode SqliteBookmarkStorage::addBookmarkedNode(const StorageBook executeStatement( "INSERT INTO bookmarked_element(id, bookmark_id) VALUES(NULL, " + std::to_string(data.bookmarkId) + ");"); - Id id = m_database.lastRowId(); + const Id id = static_cast(m_database.lastRowId()); std::string statement = "INSERT INTO bookmarked_node(id, serialized_node_name) " @@ -125,7 +125,7 @@ StorageBookmarkedEdge SqliteBookmarkStorage::addBookmarkedEdge(const StorageBook executeStatement( "INSERT INTO bookmarked_element(id, bookmark_id) VALUES(NULL, " + std::to_string(data.bookmarkId) + ");"); - Id id = m_database.lastRowId(); + const Id id = static_cast(m_database.lastRowId()); std::string statement = "INSERT INTO bookmarked_edge(id, serialized_source_node_name, serialized_target_node_name, " diff --git a/src/lib/data/storage/sqlite/SqliteIndexStorage.cpp b/src/lib/data/storage/sqlite/SqliteIndexStorage.cpp index ab87e904..c1c3005b 100644 --- a/src/lib/data/storage/sqlite/SqliteIndexStorage.cpp +++ b/src/lib/data/storage/sqlite/SqliteIndexStorage.cpp @@ -89,14 +89,14 @@ std::vector SqliteIndexStorage::addNodes(const std::vector& nod std::string name = utility::encodeToUtf8(node.serializedName); if (name.size() != node.serializedName.size()) { - m_tempWNodeNameIndex.add(node.serializedName, node.id); + m_tempWNodeNameIndex.add(node.serializedName, static_cast(node.id)); } else { - m_tempNodeNameIndex.add(name, node.id); + m_tempNodeNameIndex.add(name, static_cast(node.id)); } - m_tempNodeTypes.emplace(node.id, node.type); + m_tempNodeTypes.emplace(static_cast(node.id), node.type); }); } @@ -119,11 +119,11 @@ std::vector SqliteIndexStorage::addNodes(const std::vector& nod if (nodeId) { - auto it = m_tempNodeTypes.find(nodeId); + auto it = m_tempNodeTypes.find(static_cast(nodeId)); if (it != m_tempNodeTypes.end() && it->second < data.type) { setNodeType(data.type, nodeId); - m_tempNodeTypes[nodeId] = data.type; + m_tempNodeTypes[static_cast(nodeId)] = data.type; } nodeIds[i] = nodeId; @@ -131,20 +131,20 @@ std::vector SqliteIndexStorage::addNodes(const std::vector& nod else { executeStatement(m_insertElementStmt); - Id id = m_database.lastRowId(); + const Id id = static_cast(m_database.lastRowId()); nodesToInsert.emplace_back(id, data); nodeIds[i] = id; if (name.size() != data.serializedName.size()) { - m_tempWNodeNameIndex.add(data.serializedName, id); + m_tempWNodeNameIndex.add(data.serializedName, static_cast(id)); } else { - m_tempNodeNameIndex.add(name, id); + m_tempNodeNameIndex.add(name, static_cast(id)); } - m_tempNodeTypes.emplace(id, data.type); + m_tempNodeTypes.emplace(static_cast(id), data.type); } } } @@ -224,7 +224,8 @@ std::vector SqliteIndexStorage::addEdges(const std::vector& edg { forEach([this](StorageEdge&& edge) { m_tempEdgeIndex.emplace( - StorageEdgeData(edge.type, edge.sourceNodeId, edge.targetNodeId), edge.id); + StorageEdgeData(edge.type, edge.sourceNodeId, edge.targetNodeId), + static_cast(edge.id)); }); } @@ -241,12 +242,12 @@ std::vector SqliteIndexStorage::addEdges(const std::vector& edg else { executeStatement(m_insertElementStmt); - Id id = m_database.lastRowId(); + const Id id = static_cast(m_database.lastRowId()); edgeIds[i] = id; edgesToInsert.emplace_back(id, data); - m_tempEdgeIndex.emplace(data, id); + m_tempEdgeIndex.emplace(data, static_cast(id)); } } @@ -272,7 +273,8 @@ std::vector SqliteIndexStorage::addLocalSymbols(const std::set name = splitLocalSymbolName(localSymbol.name); if (name.second.size()) { - m_tempLocalSymbolIndex[name.first].emplace(name.second, localSymbol.id); + m_tempLocalSymbolIndex[name.first].emplace( + name.second, static_cast(localSymbol.id)); } }); } @@ -300,13 +302,13 @@ std::vector SqliteIndexStorage::addLocalSymbols(const std::set(m_database.lastRowId()); symbolIds[i] = id; symbolsToInsert.emplace_back(id, data); if (name.second.size()) { - m_tempLocalSymbolIndex[name.first].emplace(name.second, id); + m_tempLocalSymbolIndex[name.first].emplace(name.second, static_cast(id)); } } @@ -333,11 +335,15 @@ std::vector SqliteIndexStorage::addSourceLocations(const std::vector([this](StorageSourceLocation&& loc) { std::map& index = - m_tempSourceLocationIndices[loc.fileNodeId]; + m_tempSourceLocationIndices[static_cast(loc.fileNodeId)]; index.emplace( TempSourceLocation( - loc.startLine, loc.endLine - loc.startLine, loc.startCol, loc.endCol, loc.type), - loc.id); + static_cast(loc.startLine), + static_cast(loc.endLine - loc.startLine), + static_cast(loc.startCol), + static_cast(loc.endCol), + loc.type), + static_cast(loc.id)); }); } @@ -349,9 +355,13 @@ std::vector SqliteIndexStorage::addSourceLocations(const std::vector(data.startLine), + static_cast(data.endLine - data.startLine), + static_cast(data.startCol), + static_cast(data.endCol), + data.type); - std::map& index = m_tempSourceLocationIndices[data.fileNodeId]; + std::map& index = m_tempSourceLocationIndices[static_cast(data.fileNodeId)]; std::map::const_iterator it = index.find(tempLoc); if (it != index.end()) { @@ -363,7 +373,7 @@ std::vector SqliteIndexStorage::addSourceLocations(const std::vector(id)); locationsToInsert.emplace_back(data); } @@ -434,7 +444,7 @@ StorageError SqliteIndexStorage::addError(const StorageErrorData& data) if (id == 0) { executeStatement(m_insertElementStmt); - id = m_database.lastRowId(); + id = static_cast(m_database.lastRowId()); m_insertErrorStmt.bind(1, int(id)); m_insertErrorStmt.bind(2, utility::encodeToUtf8(sanitizedMessage).c_str()); @@ -445,7 +455,7 @@ StorageError SqliteIndexStorage::addError(const StorageErrorData& data) const bool success = executeStatement(m_insertErrorStmt); if (success) { - id = m_database.lastRowId(); + id = static_cast(m_database.lastRowId()); } } @@ -1349,35 +1359,35 @@ void SqliteIndexStorage::setupPrecompiledStatements() "INSERT INTO node(id, type, serialized_name) VALUES", 3, [](CppSQLite3Statement& stmt, const StorageNode& node, size_t index) { - stmt.bind(index * 3 + 1, int(node.id)); - stmt.bind(index * 3 + 2, int(node.type)); - stmt.bind(index * 3 + 3, utility::encodeToUtf8(node.serializedName).c_str()); + stmt.bind(int(index) * 3 + 1, int(node.id)); + stmt.bind(int(index) * 3 + 2, int(node.type)); + stmt.bind(int(index) * 3 + 3, utility::encodeToUtf8(node.serializedName).c_str()); }, m_database); m_insertEdgeBatchStatement.compile( "INSERT INTO edge(id, type, source_node_id, target_node_id) VALUES", 4, [](CppSQLite3Statement& stmt, const StorageEdge& edge, size_t index) { - stmt.bind(index * 4 + 1, int(edge.id)); - stmt.bind(index * 4 + 2, int(edge.type)); - stmt.bind(index * 4 + 3, int(edge.sourceNodeId)); - stmt.bind(index * 4 + 4, int(edge.targetNodeId)); + stmt.bind(int(index) * 4 + 1, int(edge.id)); + stmt.bind(int(index) * 4 + 2, int(edge.type)); + stmt.bind(int(index) * 4 + 3, int(edge.sourceNodeId)); + stmt.bind(int(index) * 4 + 4, int(edge.targetNodeId)); }, m_database); m_insertSymbolBatchStatement.compile( "INSERT OR IGNORE INTO symbol(id, definition_kind) VALUES", 2, [](CppSQLite3Statement& stmt, const StorageSymbol& symbol, size_t index) { - stmt.bind(index * 2 + 1, int(symbol.id)); - stmt.bind(index * 2 + 2, int(symbol.definitionKind)); + stmt.bind(int(index) * 2 + 1, int(symbol.id)); + stmt.bind(int(index) * 2 + 2, int(symbol.definitionKind)); }, m_database); m_insertLocalSymbolBatchStatement.compile( "INSERT INTO local_symbol(id, name) VALUES", 2, [](CppSQLite3Statement& stmt, const StorageLocalSymbol& symbol, size_t index) { - stmt.bind(index * 2 + 1, int(symbol.id)); - stmt.bind(index * 2 + 2, utility::encodeToUtf8(symbol.name).c_str()); + stmt.bind(int(index) * 2 + 1, int(symbol.id)); + stmt.bind(int(index) * 2 + 2, utility::encodeToUtf8(symbol.name).c_str()); }, m_database); m_insertSourceLocationBatchStatement.compile( @@ -1385,28 +1395,28 @@ void SqliteIndexStorage::setupPrecompiledStatements() "end_column, type) VALUES", 6, [](CppSQLite3Statement& stmt, const StorageSourceLocationData& location, size_t index) { - stmt.bind(index * 6 + 1, int(location.fileNodeId)); - stmt.bind(index * 6 + 2, int(location.startLine)); - stmt.bind(index * 6 + 3, int(location.startCol)); - stmt.bind(index * 6 + 4, int(location.endLine)); - stmt.bind(index * 6 + 5, int(location.endCol)); - stmt.bind(index * 6 + 6, int(location.type)); + stmt.bind(int(index) * 6 + 1, int(location.fileNodeId)); + stmt.bind(int(index) * 6 + 2, int(location.startLine)); + stmt.bind(int(index) * 6 + 3, int(location.startCol)); + stmt.bind(int(index) * 6 + 4, int(location.endLine)); + stmt.bind(int(index) * 6 + 5, int(location.endCol)); + stmt.bind(int(index) * 6 + 6, int(location.type)); }, m_database); m_insertOccurenceBatchStatement.compile( "INSERT OR IGNORE INTO occurrence(element_id, source_location_id) VALUES", 2, [](CppSQLite3Statement& stmt, const StorageOccurrence& occurrence, size_t index) { - stmt.bind(index * 2 + 1, int(occurrence.elementId)); - stmt.bind(index * 2 + 2, int(occurrence.sourceLocationId)); + stmt.bind(int(index) * 2 + 1, int(occurrence.elementId)); + stmt.bind(int(index) * 2 + 2, int(occurrence.sourceLocationId)); }, m_database); m_insertComponentAccessBatchStatement.compile( "INSERT OR IGNORE INTO component_access(node_id, type) VALUES", 2, [](CppSQLite3Statement& stmt, const StorageComponentAccess& componentAccess, size_t index) { - stmt.bind(index * 2 + 1, int(componentAccess.nodeId)); - stmt.bind(index * 2 + 2, int(componentAccess.type)); + stmt.bind(int(index) * 2 + 1, int(componentAccess.nodeId)); + stmt.bind(int(index) * 2 + 2, int(componentAccess.type)); }, m_database); diff --git a/src/lib/project/Project.cpp b/src/lib/project/Project.cpp index 4394f4c8..80b1e3bd 100644 --- a/src/lib/project/Project.cpp +++ b/src/lib/project/Project.cpp @@ -599,7 +599,8 @@ void Project::buildIndex(RefreshInfo info, std::shared_ptr dialogVie size_t sourceFileCount = indexerCommandProvider->size() + customIndexerCommandProvider->size(); taskSequential->addTask(std::make_shared>("shallow_indexing", info.shallow)); - taskSequential->addTask(std::make_shared>("source_file_count", sourceFileCount)); + taskSequential->addTask(std::make_shared>( + "source_file_count", static_cast(sourceFileCount))); taskSequential->addTask(std::make_shared>("indexed_source_file_count", 0)); taskSequential->addTask(std::make_shared>("interrupted_indexing", false)); taskSequential->addTask(std::make_shared>("index_time", 0.0f)); @@ -617,7 +618,7 @@ void Project::buildIndex(RefreshInfo info, std::shared_ptr dialogVie if (!indexerCommandProvider->empty()) { const int adjustedIndexerThreadCount = std::min( - indexerThreadCount, indexerCommandProvider->size()); + indexerThreadCount, static_cast(indexerCommandProvider->size())); std::shared_ptr storageProvider = std::make_shared(); // add tasks for setting some variables on the blackboard that are used during indexing @@ -719,7 +720,7 @@ void Project::buildIndex(RefreshInfo info, std::shared_ptr dialogVie if (!customIndexerCommandProvider->empty()) { const int adjustedIndexerThreadCount = std::min( - indexerThreadCount, customIndexerCommandProvider->size()); + indexerThreadCount, static_cast(customIndexerCommandProvider->size())); taskSequential->addTask(std::make_shared( std::move(customIndexerCommandProvider), @@ -813,7 +814,7 @@ bool Project::swapToTempStorageFile( FileSystem::remove(indexDbFilePath); FileSystem::rename(tempIndexDbFilePath, indexDbFilePath); } - catch (std::exception& e) + catch (std::exception& /*e*/) { if (m_hasGUI) { diff --git a/src/lib/settings/ProjectSettings.cpp b/src/lib/settings/ProjectSettings.cpp index 8d1780e7..cc8ea30f 100644 --- a/src/lib/settings/ProjectSettings.cpp +++ b/src/lib/settings/ProjectSettings.cpp @@ -472,6 +472,11 @@ SettingsMigrator ProjectSettings::getMigrations() const languageName = "java"; break; #endif // BUILD_JAVA_LANGUAGE_PACKAGE +#if BUILD_PYTHON_LANGUAGE_PACKAGE + case LANGUAGE_PYTHON: + continue; +#endif // BUILD_PYTHON_LANGUAGE_PACKAGE + default: continue; } diff --git a/src/lib/settings/Settings.cpp b/src/lib/settings/Settings.cpp index 327a4b72..84669aec 100644 --- a/src/lib/settings/Settings.cpp +++ b/src/lib/settings/Settings.cpp @@ -96,7 +96,7 @@ size_t Settings::getVersion() const void Settings::setVersion(size_t version) { - setValue("version", version); + setValue("version", static_cast(version)); } Settings::Settings() diff --git a/src/lib/settings/source_group/SourceGroupSettingsWithComponents.h b/src/lib/settings/source_group/SourceGroupSettingsWithComponents.h index 1a8f30fb..9ca68bca 100644 --- a/src/lib/settings/source_group/SourceGroupSettingsWithComponents.h +++ b/src/lib/settings/source_group/SourceGroupSettingsWithComponents.h @@ -23,8 +23,8 @@ public: SourceGroupSettings::load(config, key); - using expand_type = int[]; - expand_type a {0, loadHelper(config, key)...}; + using expand_type = bool[]; + expand_type a {false, loadHelper(config, key)...}; } void saveSettings(ConfigManager* config) override @@ -33,8 +33,8 @@ public: SourceGroupSettings::save(config, key); - using expand_type = int[]; - expand_type a {0, saveHelper(config, key)...}; + using expand_type = bool[]; + expand_type a {false, saveHelper(config, key)...}; } bool equalsSettings(const SourceGroupSettingsBase* other) override @@ -51,7 +51,7 @@ public: return false; } - using expand_type = int[]; + using expand_type = bool[]; expand_type a {false, equalsHelper(other)...}; bool r = true; diff --git a/src/lib/utility/LowMemoryStringMap.h b/src/lib/utility/LowMemoryStringMap.h index 4d445dac..16d061a3 100644 --- a/src/lib/utility/LowMemoryStringMap.h +++ b/src/lib/utility/LowMemoryStringMap.h @@ -32,7 +32,10 @@ public: static CharT* CopyFn(CharT* destination, const CharT* source, size_t num) { +#pragma warning(push) +#pragma warning(disable : 4996) return strncpy(destination, source, num); +#pragma warning(pop) } }; @@ -50,7 +53,10 @@ public: static CharT* CopyFn(CharT* destination, const CharT* source, size_t num) { +#pragma warning(push) +#pragma warning(disable : 4996) return wcsncpy(destination, source, num); +#pragma warning(pop) } }; diff --git a/src/lib/utility/TimeStamp.cpp b/src/lib/utility/TimeStamp.cpp index 5278c16a..39116347 100644 --- a/src/lib/utility/TimeStamp.cpp +++ b/src/lib/utility/TimeStamp.cpp @@ -23,7 +23,7 @@ std::string TimeStamp::secondsToString(double secs) int seconds = int(secs); secs -= seconds; - int milliSeconds = secs * 1000; + const int milliSeconds = static_cast(secs * 1000); if (hours > 9) { @@ -110,12 +110,12 @@ std::string TimeStamp::dayOfWeekShort() const size_t TimeStamp::deltaMS(const TimeStamp& other) const { - return abs((m_time - other.m_time).total_milliseconds()); + return static_cast(abs((m_time - other.m_time).total_milliseconds())); } size_t TimeStamp::deltaS(const TimeStamp& other) const { - return abs((m_time - other.m_time).total_seconds()); + return static_cast(abs((m_time - other.m_time).total_seconds())); } bool TimeStamp::isSameDay(const TimeStamp& other) const @@ -139,5 +139,5 @@ size_t TimeStamp::deltaDays(const TimeStamp& other) const size_t TimeStamp::deltaHours(const TimeStamp& other) const { boost::posix_time::time_duration delta = m_time - other.m_time; - return abs(delta.total_seconds() / 3600); + return static_cast(abs(delta.total_seconds() / 3600)); } diff --git a/src/lib/utility/file/FilePath.cpp b/src/lib/utility/file/FilePath.cpp index 27bb55f5..bab3c33a 100644 --- a/src/lib/utility/file/FilePath.cpp +++ b/src/lib/utility/file/FilePath.cpp @@ -261,8 +261,11 @@ std::vector FilePath::expandEnvironmentVariables() const std::smatch match; while (std::regex_search(text, match, env)) { +#pragma warning(push) +#pragma warning(disable : 4996) const char* s = match[1].matched ? getenv(match[1].str().c_str()) : getenv(match[2].str().c_str()); +#pragma warning(pop) if (s == nullptr) { LOG_ERROR_STREAM(<< match[1].str() << " is not an environment variable in: " << text); diff --git a/src/lib/utility/file/utilityFile.cpp b/src/lib/utility/file/utilityFile.cpp index 8a780c03..a51ba44a 100644 --- a/src/lib/utility/file/utilityFile.cpp +++ b/src/lib/utility/file/utilityFile.cpp @@ -28,7 +28,7 @@ std::vector utility::partitionFilePathsBySize(std::vector fi sourceFileSizesToCommands.end(), [](const PairType& p, const PairType& q) { return p.first > q.first; }); - if (0 < partitionCount && partitionCount < sourceFileSizesToCommands.size()) + if (0 < partitionCount && partitionCount < static_cast(sourceFileSizesToCommands.size())) { for (int i = 0; i < partitionCount; i++) { diff --git a/src/lib/utility/interprocess/SharedMemory.cpp b/src/lib/utility/interprocess/SharedMemory.cpp index b0da3c4e..ebf23a4e 100644 --- a/src/lib/utility/interprocess/SharedMemory.cpp +++ b/src/lib/utility/interprocess/SharedMemory.cpp @@ -195,7 +195,6 @@ SharedMemory::~SharedMemory() LOG_ERROR_STREAM( << "boost exception thrown at shared memory destruction - " << getMemoryName() << ": " << e.what()); - throw e; } } diff --git a/src/lib/utility/logging/FileLogger.cpp b/src/lib/utility/logging/FileLogger.cpp index be421db8..e5221e3f 100644 --- a/src/lib/utility/logging/FileLogger.cpp +++ b/src/lib/utility/logging/FileLogger.cpp @@ -13,6 +13,9 @@ std::wstring FileLogger::generateDatedFileName( { time_t time; std::time(&time); + +#pragma warning(push) +#pragma warning(disable : 4996) tm t = *std::localtime(&time); if (offsetDays != 0) @@ -20,6 +23,7 @@ std::wstring FileLogger::generateDatedFileName( time = mktime(&t) + offsetDays * 24 * 60 * 60; t = *std::localtime(&time); } +#pragma warning(pop) std::wstringstream filename; if (!prefix.empty()) diff --git a/src/lib/utility/logging/LogManagerImplementation.cpp b/src/lib/utility/logging/LogManagerImplementation.cpp index 68f1a434..37bb8f10 100644 --- a/src/lib/utility/logging/LogManagerImplementation.cpp +++ b/src/lib/utility/logging/LogManagerImplementation.cpp @@ -79,7 +79,7 @@ void LogManagerImplementation::clearLoggers() int LogManagerImplementation::getLoggerCount() const { std::lock_guard lockGuard(m_loggerMutex); - return m_loggers.size(); + return static_cast(m_loggers.size()); } void LogManagerImplementation::logInfo( @@ -128,7 +128,12 @@ tm LogManagerImplementation::getTime() { time_t time; std::time(&time); + +#pragma warning(push) +#pragma warning(disable : 4996) tm result = *std::localtime(&time); // this is done because localtime returns a pointer to a // statically allocated object +#pragma warning(pop) + return result; } diff --git a/src/lib/utility/math/MatrixDynamicBase.h b/src/lib/utility/math/MatrixDynamicBase.h index d2b0ada9..b6802820 100644 --- a/src/lib/utility/math/MatrixDynamicBase.h +++ b/src/lib/utility/math/MatrixDynamicBase.h @@ -70,7 +70,7 @@ void MatrixDynamicBase::setValue( template unsigned int MatrixDynamicBase::getColumnsCount() const { - return m_values.size(); + return static_cast(m_values.size()); } template @@ -78,7 +78,7 @@ unsigned int MatrixDynamicBase::getRowsCount() const { if (m_values.size() > 0) { - return m_values[0].size(); + return static_cast(m_values[0].size()); } return 0; diff --git a/src/lib/utility/scheduling/TaskGroupParallel.cpp b/src/lib/utility/scheduling/TaskGroupParallel.cpp index 74ee8342..1fd66ca8 100644 --- a/src/lib/utility/scheduling/TaskGroupParallel.cpp +++ b/src/lib/utility/scheduling/TaskGroupParallel.cpp @@ -22,7 +22,7 @@ void TaskGroupParallel::doEnter(std::shared_ptr blackboard) if (m_needsToStartThreads) { m_needsToStartThreads = false; - m_activeTaskCount = m_tasks.size(); + m_activeTaskCount = static_cast(m_tasks.size()); for (size_t i = 0; i < m_tasks.size(); i++) { m_tasks[i]->active = true; diff --git a/src/lib/utility/text/TextAccess.cpp b/src/lib/utility/text/TextAccess.cpp index 2a4c7d36..92f686ed 100644 --- a/src/lib/utility/text/TextAccess.cpp +++ b/src/lib/utility/text/TextAccess.cpp @@ -81,7 +81,7 @@ TextAccess::~TextAccess() {} unsigned int TextAccess::getLineCount() const { - return m_lines.size(); + return static_cast(m_lines.size()); } bool TextAccess::isEmpty() const diff --git a/src/lib/utility/tracing.cpp b/src/lib/utility/tracing.cpp index 5d17803d..6300873b 100644 --- a/src/lib/utility/tracing.cpp +++ b/src/lib/utility/tracing.cpp @@ -119,12 +119,12 @@ void Tracer::printTraces() if (p.second) { acc->event = event.get(); - acc->time = event->time; + acc->time = static_cast(event->time); acc->count = 1; } else { - acc->time += event->time; + acc->time += static_cast(event->time); acc->count++; } } diff --git a/src/lib/utility/utilityWindows.cpp b/src/lib/utility/utilityWindows.cpp index 6b4db472..80681719 100644 --- a/src/lib/utility/utilityWindows.cpp +++ b/src/lib/utility/utilityWindows.cpp @@ -7,9 +7,9 @@ unsigned long utility::getLargestByteSizeOfAllocatableMemory() { MEMORY_BASIC_INFORMATION mbi; - unsigned long start = 0; + __int64 start = 0; bool recording = false; - unsigned long freestart = 0, largestFreestart = 0; + __int64 freestart = 0, largestFreestart = 0; __int64 free = 0, largestFree = 0; while (true) @@ -39,10 +39,10 @@ unsigned long utility::getLargestByteSizeOfAllocatableMemory() free = 0; recording = false; } - start += mbi.RegionSize; + start += static_cast(mbi.RegionSize); } - return largestFree; + return static_cast(largestFree); } #endif // WIN32 diff --git a/src/lib_cxx/data/parser/cxx/GeneratePCHAction.h b/src/lib_cxx/data/parser/cxx/GeneratePCHAction.h index 48900d3d..e5646246 100644 --- a/src/lib_cxx/data/parser/cxx/GeneratePCHAction.h +++ b/src/lib_cxx/data/parser/cxx/GeneratePCHAction.h @@ -1,7 +1,7 @@ #ifndef GENERATE_PCH_ACTION_H #define GENERATE_PCH_ACTION_H -#include "clang/Frontend/FrontendActions.h" +#include class ParserClient; class CanonicalFilePathCache; diff --git a/src/lib_cxx/data/parser/cxx/SingleFrontendActionFactory.h b/src/lib_cxx/data/parser/cxx/SingleFrontendActionFactory.h index e7d6d180..7f229007 100644 --- a/src/lib_cxx/data/parser/cxx/SingleFrontendActionFactory.h +++ b/src/lib_cxx/data/parser/cxx/SingleFrontendActionFactory.h @@ -1,7 +1,7 @@ #ifndef SINGLE_FRONTEND_ACTION_FACTORY #define SINGLE_FRONTEND_ACTION_FACTORY -#include "clang/Tooling/Tooling.h" +#include class SingleFrontendActionFactory: public clang::tooling::FrontendActionFactory { diff --git a/src/lib_cxx/data/parser/cxx/name_resolver/CxxDeclNameResolver.cpp b/src/lib_cxx/data/parser/cxx/name_resolver/CxxDeclNameResolver.cpp index e21f04c3..ff0d5ba1 100644 --- a/src/lib_cxx/data/parser/cxx/name_resolver/CxxDeclNameResolver.cpp +++ b/src/lib_cxx/data/parser/cxx/name_resolver/CxxDeclNameResolver.cpp @@ -167,7 +167,7 @@ std::unique_ptr CxxDeclNameResolver::getDeclName(const clang::Named std::vector templateArguments; const clang::TemplateArgumentList& templateArgumentList = templateSpecialitarionDecl->getTemplateArgs(); - for (size_t i = 0; i < templateArgumentList.size(); i++) + for (unsigned i = 0; i < templateArgumentList.size(); i++) { if (templateArgumentList.get(i).isDependent()) { @@ -220,7 +220,7 @@ std::unique_ptr CxxDeclNameResolver::getDeclName(const clang::Named { const clang::TemplateArgumentList* templateArgumentList = functionDecl->getTemplateSpecializationArgs(); - for (size_t i = 0; i < templateArgumentList->size(); i++) + for (unsigned i = 0; i < templateArgumentList->size(); i++) { const clang::TemplateArgument& templateArgument = templateArgumentList->get(i); if (templateArgument.isDependent()) @@ -402,7 +402,7 @@ std::unique_ptr CxxDeclNameResolver::getDeclName(const clang::Named clang::dyn_cast_or_null(varDecl); const clang::TemplateArgumentList& templateArgumentList = templateSpecializationDeclaration->getTemplateArgs(); - for (size_t i = 0; i < templateArgumentList.size(); i++) + for (unsigned i = 0; i < templateArgumentList.size(); i++) { const clang::TemplateArgument& templateArgument = templateArgumentList.get(i); if (templateArgument.isDependent()) @@ -484,7 +484,7 @@ std::vector CxxDeclNameResolver::getTemplateParameterStrings( { std::vector templateParameterStrings; clang::TemplateParameterList* parameterList = templateDecl->getTemplateParameters(); - for (size_t i = 0; i < parameterList->size(); i++) + for (unsigned i = 0; i < parameterList->size(); i++) { templateParameterStrings.push_back(getTemplateParameterString(parameterList->getParam(i))); } diff --git a/src/lib_cxx/data/parser/cxx/name_resolver/CxxDeclNameResolver.h b/src/lib_cxx/data/parser/cxx/name_resolver/CxxDeclNameResolver.h index c0042320..620a166d 100644 --- a/src/lib_cxx/data/parser/cxx/name_resolver/CxxDeclNameResolver.h +++ b/src/lib_cxx/data/parser/cxx/name_resolver/CxxDeclNameResolver.h @@ -43,7 +43,7 @@ std::vector CxxDeclNameResolver::getTemplateParameterStringsOfPart const clang::TemplateArgumentList& templateArgumentList = partialSpecializationDecl->getTemplateArgs(); - for (int i = 0; i < templateArgumentList.size(); i++) + for (unsigned i = 0; i < templateArgumentList.size(); i++) { const clang::TemplateArgument& templateArgument = templateArgumentList.get(i); const clang::TemplateArgument::ArgKind argKind = templateArgument.getKind(); diff --git a/src/lib_cxx/data/parser/cxx/name_resolver/CxxTemplateParameterStringResolver.cpp b/src/lib_cxx/data/parser/cxx/name_resolver/CxxTemplateParameterStringResolver.cpp index d1010d50..91b5b67b 100644 --- a/src/lib_cxx/data/parser/cxx/name_resolver/CxxTemplateParameterStringResolver.cpp +++ b/src/lib_cxx/data/parser/cxx/name_resolver/CxxTemplateParameterStringResolver.cpp @@ -89,7 +89,7 @@ std::wstring CxxTemplateParameterStringResolver::getTemplateParameterTypeString( std::wstringstream ss; ss << L"template<"; const clang::TemplateParameterList* parameterList = parameter->getTemplateParameters(); - for (size_t i = 0; i < parameterList->size(); i++) + for (unsigned i = 0; i < parameterList->size(); i++) { if (i > 0) { diff --git a/src/lib_cxx/data/parser/cxx/name_resolver/CxxTypeNameResolver.cpp b/src/lib_cxx/data/parser/cxx/name_resolver/CxxTypeNameResolver.cpp index c574c697..15c7630c 100644 --- a/src/lib_cxx/data/parser/cxx/name_resolver/CxxTypeNameResolver.cpp +++ b/src/lib_cxx/data/parser/cxx/name_resolver/CxxTypeNameResolver.cpp @@ -160,7 +160,7 @@ std::unique_ptr CxxTypeNameResolver::getName(const clang::Type* typ resolver.ignoreContextDecl(templateSpecializationType->getTemplateName() .getAsTemplateDecl() ->getTemplatedDecl()); - for (size_t i = 0; i < templateSpecializationType->getNumArgs(); i++) + for (unsigned i = 0; i < templateSpecializationType->getNumArgs(); i++) { if (templateSpecializationType->getArg(i).isDependent()) { @@ -218,7 +218,7 @@ std::unique_ptr CxxTypeNameResolver::getName(const clang::Type* typ std::vector templateArguments; CxxTemplateArgumentNameResolver resolver(this); - for (size_t i = 0; i < dependentType->getNumArgs(); i++) + for (unsigned i = 0; i < dependentType->getNumArgs(); i++) { templateArguments.push_back( resolver.getTemplateArgumentName(dependentType->getArg(i))); @@ -255,7 +255,7 @@ std::unique_ptr CxxTypeNameResolver::getName(const clang::Type* typ std::wstring nameString = CxxTypeName::makeUnsolvedIfNull(getName(protoType->getReturnType()))->toString(); nameString += L"("; - for (size_t i = 0; i < protoType->getNumParams(); i++) + for (unsigned i = 0; i < protoType->getNumParams(); i++) { if (i != 0) { diff --git a/src/lib_cxx/data/parser/cxx/utilityClang.cpp b/src/lib_cxx/data/parser/cxx/utilityClang.cpp index cd4f1065..e8f5b6ec 100644 --- a/src/lib_cxx/data/parser/cxx/utilityClang.cpp +++ b/src/lib_cxx/data/parser/cxx/utilityClang.cpp @@ -68,6 +68,8 @@ AccessKind utility::convertAccessSpecifier(clang::AccessSpecifier access) return ACCESS_PRIVATE; case clang::AS_none: return ACCESS_NONE; + default: + return ACCESS_NONE; } } @@ -85,6 +87,8 @@ SymbolKind utility::convertTagKind(const clang::TagTypeKind tagKind) return SYMBOL_ENUM; case clang::TTK_Interface: return SYMBOL_KIND_MAX; + default: + return SYMBOL_KIND_MAX; } } diff --git a/src/lib_cxx/utility/IncludeProcessing.cpp b/src/lib_cxx/utility/IncludeProcessing.cpp index 087a5650..3baad248 100644 --- a/src/lib_cxx/utility/IncludeProcessing.cpp +++ b/src/lib_cxx/utility/IncludeProcessing.cpp @@ -162,7 +162,7 @@ std::vector IncludeProcessing::getIncludeDirectives( TextCodec codec(ApplicationSettings::getInstance()->getTextEncoding()); const std::vector lines = textAccess->getAllLines(); - for (size_t i = 0; i < lines.size(); i++) + for (unsigned i = 0; i < lines.size(); i++) { const std::wstring line = codec.decode(lines[i]); const std::wstring lineTrimmedToHash = utility::trim(line); diff --git a/src/lib_gui/platform_includes/includesWindows.h b/src/lib_gui/platform_includes/includesWindows.h index fb265b03..f6e5629f 100644 --- a/src/lib_gui/platform_includes/includesWindows.h +++ b/src/lib_gui/platform_includes/includesWindows.h @@ -41,11 +41,14 @@ void setupApp(int argc, char* argv[]) FilePath userDataPath = AppPath::getAppPath().concatenate(L"user/"); if (!userDataPath.exists()) { +#pragma warning(push) +#pragma warning(disable : 4996) FilePath userLocalPath = FilePath(std::string(std::getenv("LOCALAPPDATA"))); if (!userLocalPath.exists()) { userLocalPath = FilePath(std::string(std::getenv("APPDATA")) + "/../local"); } +#pragma warning(pop) if (userLocalPath.exists()) { diff --git a/src/lib_gui/qt/element/QtStatusBar.cpp b/src/lib_gui/qt/element/QtStatusBar.cpp index 02da2af9..d2d0bbb6 100644 --- a/src/lib_gui/qt/element/QtStatusBar.cpp +++ b/src/lib_gui/qt/element/QtStatusBar.cpp @@ -167,7 +167,7 @@ void QtStatusBar::showIndexingProgress(size_t progressPercent) m_indexingStatus->show(); m_vlineIndexing->show(); - m_indexingProgress->setValue(progressPercent); + m_indexingProgress->setValue(static_cast(progressPercent)); } void QtStatusBar::hideIndexingProgress() diff --git a/src/lib_gui/qt/element/QtTable.cpp b/src/lib_gui/qt/element/QtTable.cpp index ae977d0e..dad75930 100644 --- a/src/lib_gui/qt/element/QtTable.cpp +++ b/src/lib_gui/qt/element/QtTable.cpp @@ -75,9 +75,10 @@ void QtTable::updateRows() } } - int rowCount = model()->rowCount() > m_rowsToFill ? model()->rowCount() : m_rowsToFill; - int width = ApplicationSettings::getInstance()->getFontSize() * 0.7 * - int(1 + std::log10(rowCount)); + const int rowCount = model()->rowCount() > m_rowsToFill ? model()->rowCount() + : static_cast(m_rowsToFill); + const int width = static_cast( + ApplicationSettings::getInstance()->getFontSize() * 0.7 * int(1 + std::log10(rowCount))); verticalHeader()->setStyleSheet("::section { width: " + QString::number(width) + "px; }"); verticalHeader()->setDefaultSectionSize(ApplicationSettings::getInstance()->getFontSize() + 6); diff --git a/src/lib_gui/qt/element/code/QtCodeArea.cpp b/src/lib_gui/qt/element/code/QtCodeArea.cpp index 80e68817..3fd42c00 100644 --- a/src/lib_gui/qt/element/code/QtCodeArea.cpp +++ b/src/lib_gui/qt/element/code/QtCodeArea.cpp @@ -134,7 +134,7 @@ QSize QtCodeArea::sizeHint() const height += horizontalScrollBar()->height(); } - return QSize(width + lineNumberAreaWidth() + 1, height + 5); + return QSize(static_cast(width + lineNumberAreaWidth() + 1), static_cast(height + 5)); } void QtCodeArea::lineNumberAreaPaintEvent(QPaintEvent* event) @@ -242,7 +242,7 @@ void QtCodeArea::lineNumberAreaPaintEvent(QPaintEvent* event) { if (block.isVisible() && bottom >= drawAreaTop) { - const int number = blockNumber + getStartLineNumber(); + const int number = static_cast(blockNumber + getStartLineNumber()); const int height = bottom - top - std::max(0, bottom - drawAreaBottom); p.setColor(textColor); @@ -274,7 +274,7 @@ void QtCodeArea::lineNumberAreaPaintEvent(QPaintEvent* event) int QtCodeArea::lineNumberDigits() const { - return utility::digits(getEndLineNumber()); + return static_cast(utility::digits(getEndLineNumber())); } int QtCodeArea::lineNumberAreaWidth() const @@ -426,7 +426,8 @@ QRectF QtCodeArea::getLineRectForLineNumber(size_t lineNumber) const lineNumber = getEndLineNumber(); } - QTextBlock block = document()->findBlockByLineNumber(lineNumber - getStartLineNumber()); + QTextBlock block = document()->findBlockByLineNumber( + static_cast(lineNumber - getStartLineNumber())); return blockBoundingGeometry(block); } @@ -447,8 +448,8 @@ void QtCodeArea::findScreenMatches( } Annotation matchAnnotation; - matchAnnotation.start = pos; - matchAnnotation.end = pos + query.size(); + matchAnnotation.start = static_cast(pos); + matchAnnotation.end = static_cast(pos + query.size()); std::pair start = toLineColumn(matchAnnotation.start); matchAnnotation.startLine = start.first; @@ -483,7 +484,8 @@ void QtCodeArea::clearScreenMatches() while (i > 0 && m_annotations[i - 1].locationType == LOCATION_SCREEN_SEARCH) { i--; - m_linesToRehighlight.push_back(m_annotations[i].startLine - getStartLineNumber()); + m_linesToRehighlight.push_back( + static_cast(m_annotations[i].startLine - getStartLineNumber())); } if (i != m_annotations.size()) @@ -555,8 +557,8 @@ void QtCodeArea::ensureLocationIdVisible(Id locationId, int parentWidth, bool an } const double percentTarget = double(targetWidth) / (totalWidth - visibleWidth); - const int newValue = (scrollBar->maximum() - scrollBar->minimum()) * percentTarget + - scrollBar->minimum(); + const int newValue = static_cast( + (scrollBar->maximum() - scrollBar->minimum()) * percentTarget + scrollBar->minimum()); if (animated && ApplicationSettings::getInstance()->getUseAnimations()) { @@ -684,7 +686,8 @@ void QtCodeArea::mouseMoveEvent(QMouseEvent* event) QScrollBar* scrollbar = horizontalScrollBar(); int visibleContentWidth = width() - lineNumberAreaWidth(); float deltaPosRatio = float(deltaX) / (visibleContentWidth); - scrollbar->setValue(scrollbar->value() - std::round(deltaPosRatio * scrollbar->pageStep())); + scrollbar->setValue(static_cast( + scrollbar->value() - std::round(deltaPosRatio * scrollbar->pageStep()))); } else if (m_isDragging) { diff --git a/src/lib_gui/qt/element/code/QtCodeField.cpp b/src/lib_gui/qt/element/code/QtCodeField.cpp index de17f193..8308d786 100644 --- a/src/lib_gui/qt/element/code/QtCodeField.cpp +++ b/src/lib_gui/qt/element/code/QtCodeField.cpp @@ -129,7 +129,7 @@ QSize QtCodeField::sizeHint() const width = std::max(blockWidth, width); } - return QSize(width + 1, height + 5); + return QSize(width + 1, static_cast(height + 5)); } size_t QtCodeField::getStartLineNumber() const @@ -144,7 +144,7 @@ size_t QtCodeField::getEndLineNumber() const int QtCodeField::totalLineHeight() const { - return blockBoundingRect(firstVisibleBlock()).height() * blockCount(); + return static_cast(blockBoundingRect(firstVisibleBlock()).height() * blockCount()); } std::string QtCodeField::getCode() const @@ -167,9 +167,9 @@ void QtCodeField::paintEvent(QPaintEvent* event) QPainter painter(viewport()); QTextBlock block = firstVisibleBlock(); - int top = blockBoundingGeometry(block).translated(contentOffset()).top(); - int bottom = top + blockBoundingRect(block).height(); - int blockHeight = blockBoundingRect(block).height(); + int top = static_cast(blockBoundingGeometry(block).translated(contentOffset()).top()); + int bottom = static_cast(top + blockBoundingRect(block).height()); + int blockHeight = static_cast(blockBoundingRect(block).height()); int firstVisibleLine = -1; int lastVisibleLine = -1; @@ -195,8 +195,8 @@ void QtCodeField::paintEvent(QPaintEvent* event) // TODO: this causes another paint event if lines get rehighlighted m_highlighter->highlightRange(firstVisibleLine, lastVisibleLine); - firstVisibleLine += m_startLineNumber; - lastVisibleLine += m_startLineNumber; + firstVisibleLine += static_cast(m_startLineNumber); + lastVisibleLine += static_cast(m_startLineNumber); int borderRadius = 3; @@ -234,7 +234,7 @@ void QtCodeField::paintEvent(QPaintEvent* event) { painter.drawRoundedRect( 0, - top + (annotation.startLine - m_startLineNumber) * blockHeight, + static_cast(top + (annotation.startLine - m_startLineNumber) * blockHeight), width(), (annotation.endLine - annotation.startLine + 1) * blockHeight, borderRadius, @@ -369,7 +369,7 @@ bool QtCodeField::annotateText( if (wasFocused != annotation.isFocused || wasActive != annotation.isActive) { - m_linesToRehighlight.push_back(annotation.startLine - m_startLineNumber); + m_linesToRehighlight.push_back(static_cast(annotation.startLine - m_startLineNumber)); } } @@ -406,14 +406,14 @@ void QtCodeField::createAnnotations(std::shared_ptr location if (!startLocation || startLocation->getLineNumber() < m_startLineNumber) { annotation.start = startTextEditPosition(); - annotation.startLine = m_startLineNumber; + annotation.startLine = static_cast(m_startLineNumber); annotation.startCol = 0; } else if (startLocation->getLineNumber() <= endLineNumber) { - const int startLine = startLocation->getLineNumber(); + const int startLine = static_cast(startLocation->getLineNumber()); const int startCol = getColumnCorrectedForMultibyteCharacters( - startLine, startLocation->getColumnNumber() - 1); + startLine, static_cast(startLocation->getColumnNumber() - 1)); annotation.start = toTextEditPosition(startLine, startCol); annotation.startLine = startLine; @@ -428,14 +428,14 @@ void QtCodeField::createAnnotations(std::shared_ptr location if (!endLocation || endLocation->getLineNumber() > endLineNumber) { annotation.end = endTextEditPosition(); - annotation.endLine = endLineNumber; + annotation.endLine = static_cast(endLineNumber); annotation.endCol = m_lineLengths[document()->blockCount() - 1]; } else if (endLocation->getLineNumber() >= m_startLineNumber) { - const int endLine = endLocation->getLineNumber(); + const int endLine = static_cast(endLocation->getLineNumber()); const int endCol = getColumnCorrectedForMultibyteCharacters( - endLine, endLocation->getColumnNumber()); + endLine, static_cast(endLocation->getColumnNumber())); annotation.end = toTextEditPosition(endLine, endCol); annotation.endLine = endLine; @@ -517,7 +517,7 @@ void QtCodeField::activateAnnotations(const std::vector& anno int QtCodeField::toTextEditPosition(int lineNumber, int columnNumber) const { - lineNumber -= m_startLineNumber - 1; + lineNumber -= static_cast(m_startLineNumber - 1); int position = 0; for (int i = 0; i < lineNumber - 1; i++) @@ -531,7 +531,7 @@ int QtCodeField::toTextEditPosition(int lineNumber, int columnNumber) const std::pair QtCodeField::toLineColumn(int textEditPosition) const { - int lineNumber = m_startLineNumber; + int lineNumber = static_cast(m_startLineNumber); for (int i = 0; i < document()->lineCount(); i++) { int nextTextEditPosition = textEditPosition - m_lineLengths[i]; diff --git a/src/lib_gui/qt/element/code/QtCodeFileList.cpp b/src/lib_gui/qt/element/code/QtCodeFileList.cpp index cef64d50..6c9b158f 100644 --- a/src/lib_gui/qt/element/code/QtCodeFileList.cpp +++ b/src/lib_gui/qt/element/code/QtCodeFileList.cpp @@ -128,7 +128,7 @@ QtCodeFile* QtCodeFileList::getFile(const FilePath& filePath) void QtCodeFileList::addFile(const CodeFileParams& params) { QtCodeFile* file = getFile(params.locationFile->getFilePath()); - file->setWholeFile(params.locationFile->isWhole(), params.referenceCount); + file->setWholeFile(params.locationFile->isWhole(), static_cast(params.referenceCount)); file->setModificationTime(params.modificationTime); file->setIsComplete(params.locationFile->isComplete()); file->setIsIndexed(params.locationFile->isIndexed()); @@ -221,7 +221,7 @@ void QtCodeFileList::scrollTo( } else if (lineNumber) { - snippet = file->getSnippetForLine(lineNumber); + snippet = file->getSnippetForLine(static_cast(lineNumber)); } else { diff --git a/src/lib_gui/qt/element/code/QtCodeFileSingle.cpp b/src/lib_gui/qt/element/code/QtCodeFileSingle.cpp index f3979128..2fa3c36b 100644 --- a/src/lib_gui/qt/element/code/QtCodeFileSingle.cpp +++ b/src/lib_gui/qt/element/code/QtCodeFileSingle.cpp @@ -115,7 +115,7 @@ bool QtCodeFileSingle::addFile(const CodeFileParams& params, bool useSingleFileC &QtCodeNavigator::scrolled); setFileData(file); - updateRefCount(params.referenceCount); + updateRefCount(static_cast(params.referenceCount)); if (useSingleFileCache) { @@ -316,7 +316,7 @@ void QtCodeFileSingle::setFileData(const FileData& file) m_titleBar->setIsIndexed(file.isIndexed); } - updateRefCount(m_area->getActiveLocationCount()); + updateRefCount(static_cast(m_area->getActiveLocationCount())); titleButton->updateTexts(); titleButton->show(); diff --git a/src/lib_gui/qt/element/code/QtCodeFileTitleButton.cpp b/src/lib_gui/qt/element/code/QtCodeFileTitleButton.cpp index 5d678c1d..944279e3 100644 --- a/src/lib_gui/qt/element/code/QtCodeFileTitleButton.cpp +++ b/src/lib_gui/qt/element/code/QtCodeFileTitleButton.cpp @@ -24,7 +24,7 @@ QtCodeFileTitleButton::QtCodeFileTitleButton(QWidget* parent) setObjectName(QStringLiteral("title_button")); minimumSizeHint(); // force font loading - setFixedHeight(std::max(fontMetrics().height() * 1.2, 28.0)); + setFixedHeight(static_cast(std::max(fontMetrics().height() * 1.2, 28.0))); setSizePolicy(sizePolicy().horizontalPolicy(), QSizePolicy::Fixed); setIconSize(QSize(16, 16)); diff --git a/src/lib_gui/qt/element/code/QtCodeNavigateable.cpp b/src/lib_gui/qt/element/code/QtCodeNavigateable.cpp index 6d1ee035..5c6d92d0 100644 --- a/src/lib_gui/qt/element/code/QtCodeNavigateable.cpp +++ b/src/lib_gui/qt/element/code/QtCodeNavigateable.cpp @@ -116,9 +116,9 @@ void QtCodeNavigateable::ensurePercentVisibleAnimated( QScrollBar* scrollBar = area->verticalScrollBar(); double scrollFactor = double(scrollBar->maximum()) / scrollableHeight; - int visibleY = double(scrollBar->value()) / scrollFactor; - int scrollY = totalHeight * percentA; - int rectHeight = percentB ? (totalHeight * percentB) - scrollY : 0; + const int visibleY = static_cast(double(scrollBar->value()) / scrollFactor); + int scrollY = static_cast(totalHeight * percentA); + const int rectHeight = percentB ? static_cast((totalHeight * percentB) - scrollY) : 0; if (rectHeight > visibleHeight) { @@ -149,8 +149,8 @@ void QtCodeNavigateable::ensurePercentVisibleAnimated( break; } - int value = scrollY * scrollFactor; - int diff = value - scrollBar->value(); + const int value = static_cast(scrollY * scrollFactor); + const int diff = value - scrollBar->value(); if (diff > 5 || diff < -5) { if (animated && ApplicationSettings::getInstance()->getUseAnimations() && area->isVisible()) diff --git a/src/lib_gui/qt/element/code/QtCodeNavigator.cpp b/src/lib_gui/qt/element/code/QtCodeNavigator.cpp index 33a6abf4..60bfdaba 100644 --- a/src/lib_gui/qt/element/code/QtCodeNavigator.cpp +++ b/src/lib_gui/qt/element/code/QtCodeNavigator.cpp @@ -555,7 +555,7 @@ void QtCodeNavigator::scrollTo(const CodeScrollParams& params, bool animated) QAbstractScrollArea* area = m_current->getScrollArea(); if (area) { - area->verticalScrollBar()->setValue(params.value); + area->verticalScrollBar()->setValue(static_cast(params.value)); } }; } diff --git a/src/lib_gui/qt/element/dialog/QtProgressBar.cpp b/src/lib_gui/qt/element/dialog/QtProgressBar.cpp index 08275c84..bd0cab74 100644 --- a/src/lib_gui/qt/element/dialog/QtProgressBar.cpp +++ b/src/lib_gui/qt/element/dialog/QtProgressBar.cpp @@ -56,7 +56,7 @@ void QtProgressBar::paintEvent(QPaintEvent* event) } else { - painter.fillRect(0, 2, geometry().width() * m_percent / 100, 6, "white"); + painter.fillRect(0, 2, static_cast(geometry().width() * m_percent / 100), 6, "white"); } } diff --git a/src/lib_gui/qt/element/search/QtAutocompletionList.cpp b/src/lib_gui/qt/element/search/QtAutocompletionList.cpp index 7c5497a4..22dc2ed0 100644 --- a/src/lib_gui/qt/element/search/QtAutocompletionList.cpp +++ b/src/lib_gui/qt/element/search/QtAutocompletionList.cpp @@ -18,13 +18,13 @@ void QtAutocompletionModel::setMatchList(const std::vector& matchLi { size_t rowCount = std::max(m_matchList.size(), matchList.size()); m_matchList = matchList; - emit dataChanged(index(0, 0), index(rowCount - 1, 5)); + emit dataChanged(index(0, 0), index(static_cast(rowCount - 1), 5)); } int QtAutocompletionModel::rowCount(const QModelIndex& parent) const { Q_UNUSED(parent); - return m_matchList.size(); + return static_cast(m_matchList.size()); } int QtAutocompletionModel::columnCount(const QModelIndex& parent) const @@ -169,7 +169,7 @@ void QtAutocompletionDelegate::paint( } int top1 = 6; - int top2 = m_charHeight1 + 3; + int top2 = static_cast(m_charHeight1 + 3); // draw background QColor backgroundColor = option.palette.color( @@ -189,10 +189,10 @@ void QtAutocompletionDelegate::paint( } QRect rect( - option.rect.left() + m_charWidth1 * (idx + 1) + 2, + static_cast(option.rect.left() + m_charWidth1 * (idx + 1) + 2), option.rect.top() + top1 - 1, - m_charWidth1 + 1, - m_charHeight1 - 1); + static_cast(m_charWidth1 + 1), + static_cast(m_charHeight1 - 1)); painter->fillRect(rect, fillColor); highlightText[idx] = text.at(idx); @@ -201,12 +201,17 @@ void QtAutocompletionDelegate::paint( } else { - QRect rect(option.rect.left(), option.rect.top() + top1, m_charWidth1 - 1, m_charHeight1 - 2); + QRect rect( + option.rect.left(), + option.rect.top() + top1, + static_cast(m_charWidth1 - 1), + static_cast(m_charHeight1 - 2)); painter->fillRect(rect, fillColor); } // draw text normal - painter->drawText(option.rect.adjusted(m_charWidth1 + 2, top1 - 3, 0, 0), Qt::AlignLeft, text); + painter->drawText( + option.rect.adjusted(static_cast(m_charWidth1 + 2), top1 - 3, 0, 0), Qt::AlignLeft, text); // draw text highlighted painter->save(); @@ -214,7 +219,9 @@ void QtAutocompletionDelegate::paint( highlightPen.setColor(textColor); painter->setPen(highlightPen); painter->drawText( - option.rect.adjusted(m_charWidth1 + 2, top1 - 3, 0, 0), Qt::AlignLeft, highlightText); + option.rect.adjusted(static_cast(m_charWidth1 + 2), top1 - 3, 0, 0), + Qt::AlignLeft, + highlightText); painter->restore(); // draw subtext @@ -222,8 +229,8 @@ void QtAutocompletionDelegate::paint( { // draw arrow icon painter->drawPixmap( - option.rect.left() + m_charWidth2 * 2, - option.rect.top() + top2 + 1 + (m_charHeight2 - m_arrow.height()) / 2, + static_cast(option.rect.left() + m_charWidth2 * 2), + static_cast(option.rect.top() + top2 + 1 + (m_charHeight2 - m_arrow.height()) / 2), m_arrow.pixmap()); painter->setFont(m_font2); @@ -240,10 +247,10 @@ void QtAutocompletionDelegate::paint( } QRect rect( - option.rect.left() + m_charWidth2 * (idx + 3) + 2, + static_cast(option.rect.left() + m_charWidth2 * (idx + 3) + 2), option.rect.top() + top2 + 1, - m_charWidth2 + 1, - m_charHeight2); + static_cast(m_charWidth2 + 1), + static_cast(m_charHeight2)); painter->fillRect(rect, fillColor); highlightSubtext[idx] = subtext.at(idx); @@ -257,7 +264,9 @@ void QtAutocompletionDelegate::paint( // draw subtext normal painter->drawText( - option.rect.adjusted((3 * m_charWidth2) + 2, top2, 0, 0), Qt::AlignLeft, subtext); + option.rect.adjusted(static_cast((3 * m_charWidth2) + 2), top2, 0, 0), + Qt::AlignLeft, + subtext); // draw subtext highlighted painter->save(); @@ -265,7 +274,9 @@ void QtAutocompletionDelegate::paint( highlightPen.setColor(textColor); painter->setPen(highlightPen); painter->drawText( - option.rect.adjusted((3 * m_charWidth2) + 2, top2, 0, 0), Qt::AlignLeft, highlightSubtext); + option.rect.adjusted(static_cast((3 * m_charWidth2) + 2), top2, 0, 0), + Qt::AlignLeft, + highlightSubtext); painter->restore(); } @@ -278,13 +289,21 @@ void QtAutocompletionDelegate::paint( typePen.setColor(scheme->getColor("search/popup/by_text").c_str()); painter->setPen(typePen); - int width = m_charWidth2 * type.size(); - int x = painter->viewport().right() - width - m_charWidth2; + int width = static_cast(m_charWidth2 * type.size()); + int x = static_cast(painter->viewport().right() - width - m_charWidth2); int y = option.rect.top() + top2; painter->fillRect( - QRect(x - m_charWidth2, y, width + m_charWidth2 * 3, m_charHeight2 + 2), backgroundColor); - painter->drawText(QRect(x, y, width + m_charWidth2, m_charHeight2), Qt::AlignRight, type); + QRect( + static_cast(x - m_charWidth2), + y, + static_cast(width + m_charWidth2 * 3), + static_cast(m_charHeight2 + 2)), + backgroundColor); + painter->drawText( + QRect(x, y, static_cast(width + m_charWidth2), static_cast(m_charHeight2)), + Qt::AlignRight, + type); } // draw bottom line @@ -303,8 +322,9 @@ QSize QtAutocompletionDelegate::sizeHint(const QStyleOptionViewItem& option, con QString type = m_model->longestType(); return QSize( - std::max((text.size() + 2) * m_charWidth1, (subtext.size() + type.size() + 6) * m_charWidth2), - m_charHeight1 * 2 + 3); + static_cast(std::max( + (text.size() + 2) * m_charWidth1, (subtext.size() + type.size() + 6) * m_charWidth2)), + static_cast(m_charHeight1 * 2 + 3)); } void QtAutocompletionDelegate::calculateCharSizes(QFont font) @@ -329,7 +349,7 @@ void QtAutocompletionDelegate::calculateCharSizes(QFont font) "---------------------------------------------------------------------------" "-------------------------")) / 500.0f; - m_charHeight1 = metrics1.height(); + m_charHeight1 = static_cast(metrics1.height()); font.setPixelSize(ApplicationSettings::getInstance()->getFontSize() - 3); m_font2 = font; @@ -347,11 +367,11 @@ void QtAutocompletionDelegate::calculateCharSizes(QFont font) "---------------------------------------------------------------------------" "-------------------------")) / 500.0f; - m_charHeight2 = metrics2.height(); + m_charHeight2 = static_cast(metrics2.height()); m_arrow = QtDeviceScaledPixmap( QString::fromStdString(ResourcePaths::getGuiPath().str() + "search_view/images/arrow.png")); - m_arrow.scaleToWidth(m_charWidth2); + m_arrow.scaleToWidth(static_cast(m_charWidth2)); m_arrow.colorize(ColorScheme::getInstance()->getColor("search/popup/by_text").c_str()); } diff --git a/src/lib_gui/qt/element/search/QtSearchBarButton.cpp b/src/lib_gui/qt/element/search/QtSearchBarButton.cpp index 133b1ea3..32f6e5d4 100644 --- a/src/lib_gui/qt/element/search/QtSearchBarButton.cpp +++ b/src/lib_gui/qt/element/search/QtSearchBarButton.cpp @@ -12,14 +12,16 @@ void QtSearchBarButton::refresh() { QtSelfRefreshIconButton::refresh(); - int size = m_small ? 10 : 16; + const int size = m_small ? 10 : 16; - float height = std::max(ApplicationSettings::getInstance()->getFontSize() + size, size + 14); - setFixedHeight(height); + const float height = std::max( + static_cast(ApplicationSettings::getInstance()->getFontSize() + size), + static_cast(size + 14)); + setFixedHeight(static_cast(height)); if (!m_small) { - int iconSize = int(height / 4) * 2 + 2; + const int iconSize = int(height / 4) * 2 + 2; setIconSize(QSize(iconSize, iconSize)); } } diff --git a/src/lib_gui/qt/element/search/QtSmartSearchBox.cpp b/src/lib_gui/qt/element/search/QtSmartSearchBox.cpp index 82fc1661..28cf9fdb 100644 --- a/src/lib_gui/qt/element/search/QtSmartSearchBox.cpp +++ b/src/lib_gui/qt/element/search/QtSmartSearchBox.cpp @@ -340,7 +340,7 @@ void QtSmartSearchBox::keyPressEvent(QKeyEvent* event) setEditText(QString::fromStdString(str)); if (size) { - setCursorPosition(size); + setCursorPosition(static_cast(size)); } requestAutoCompletions(); @@ -437,7 +437,7 @@ void QtSmartSearchBox::keyPressEvent(QKeyEvent* event) if (m_cursorIndex < m_elements.size()) { editTextToElement(); - moveCursorTo(m_elements.size()); + moveCursorTo(static_cast(m_elements.size())); return; } } @@ -555,7 +555,7 @@ void QtSmartSearchBox::mouseReleaseEvent(QMouseEvent* event) int dist = m_elements[i]->x() + m_elements[i]->width() - event->x(); if (abs(dist) < abs(minDist)) { - pos = i + 1; + pos = static_cast(i) + 1; minDist = dist; } } @@ -565,7 +565,7 @@ void QtSmartSearchBox::mouseReleaseEvent(QMouseEvent* event) if (pos - m_cursorIndex != 0) { - moveCursor(pos - m_cursorIndex); + moveCursor(static_cast(pos - m_cursorIndex)); } else if (hasSelected) { @@ -707,7 +707,7 @@ void QtSmartSearchBox::onElementSelected(QtSearchElement* element) void QtSmartSearchBox::moveCursor(int offset) { - moveCursorTo(m_cursorIndex + offset); + moveCursorTo(static_cast(m_cursorIndex + offset)); } void QtSmartSearchBox::moveCursorTo(int target) @@ -788,7 +788,7 @@ bool QtSmartSearchBox::editTextToElement() SearchMatch QtSmartSearchBox::editElement(QtSearchElement* element) { - for (int i = m_elements.size() - 1; i >= 0; i--) + for (int i = static_cast(m_elements.size() - 1); i >= 0; i--) { if (m_elements[i] == element) { @@ -939,7 +939,7 @@ void QtSmartSearchBox::layoutElements() { QtSearchElement* button = m_elements[i]; QSize size = button->minimumSizeHint(); - int y = (rect().height() - size.height()) / 2.0; + const int y = static_cast((rect().height() - size.height()) / 2.0); button->setGeometry(elementX[i] + offsetX, y, size.width(), size.height()); } diff --git a/src/lib_gui/qt/graphics/base/QtCountCircleItem.cpp b/src/lib_gui/qt/graphics/base/QtCountCircleItem.cpp index 279e4ad2..ac3d329d 100644 --- a/src/lib_gui/qt/graphics/base/QtCountCircleItem.cpp +++ b/src/lib_gui/qt/graphics/base/QtCountCircleItem.cpp @@ -13,7 +13,7 @@ QtCountCircleItem::QtCountCircleItem(QGraphicsItem* parent): QtRoundedRectItem(p QFont font; font.setFamily(GraphViewStyle::getFontNameOfExpandToggleNode().c_str()); - font.setPixelSize(GraphViewStyle::getFontSizeOfCountCircle()); + font.setPixelSize(static_cast(GraphViewStyle::getFontSizeOfCountCircle())); font.setWeight(QFont::Normal); m_number = new QGraphicsSimpleTextItem(this); @@ -38,17 +38,17 @@ void QtCountCircleItem::setPosition(const Vec2f& pos) void QtCountCircleItem::setNumber(size_t number) { - QString numberStr = QString::number(number); + const QString numberStr = QString::number(number); m_number->setText(numberStr); - QPointF center = this->rect().center(); - this->setPosition(Vec2f(center.x(), center.y())); + const QPointF center = this->rect().center(); + this->setPosition(Vec2f(static_cast(center.x()), static_cast(center.y()))); } void QtCountCircleItem::setStyle(QColor color, QColor fontColor, QColor borderColor, size_t borderWidth) { this->setBrush(color); - this->setPen(QPen(borderColor, borderWidth)); + this->setPen(QPen(borderColor, static_cast(borderWidth))); m_number->setBrush(fontColor); } diff --git a/src/lib_gui/qt/graphics/base/QtGraphicsView.cpp b/src/lib_gui/qt/graphics/base/QtGraphicsView.cpp index 33ef4761..9319ba99 100644 --- a/src/lib_gui/qt/graphics/base/QtGraphicsView.cpp +++ b/src/lib_gui/qt/graphics/base/QtGraphicsView.cpp @@ -241,11 +241,11 @@ void QtGraphicsView::updateZoom(float delta) if (factor <= 0.0f) { - factor = 0.000001; + factor = 0.000001f; } double newZoom = m_zoomFactor * factor; - setZoomFactor(qBound(0.1, newZoom, 100.0)); + setZoomFactor(static_cast(qBound(0.1, newZoom, 100.0))); } void QtGraphicsView::resizeEvent(QResizeEvent* event) @@ -373,7 +373,7 @@ void QtGraphicsView::wheelEvent(QWheelEvent* event) { if (event->delta() != 0.0f) { - updateZoom(event->delta()); + updateZoom(static_cast(event->delta())); } } else @@ -536,12 +536,12 @@ void QtGraphicsView::updateTimer() if (x != 0) { - horizontalScrollBar()->setValue(horizontalScrollBar()->value() + x); + horizontalScrollBar()->setValue(static_cast(horizontalScrollBar()->value() + x)); } if (y != 0) { - verticalScrollBar()->setValue(verticalScrollBar()->value() + y); + verticalScrollBar()->setValue(static_cast(verticalScrollBar()->value() + y)); } if (z != 0) diff --git a/src/lib_gui/qt/graphics/base/QtLineItemAngled.cpp b/src/lib_gui/qt/graphics/base/QtLineItemAngled.cpp index 5b4a5d24..7c0fd9e0 100644 --- a/src/lib_gui/qt/graphics/base/QtLineItemAngled.cpp +++ b/src/lib_gui/qt/graphics/base/QtLineItemAngled.cpp @@ -79,11 +79,11 @@ void QtLineItemAngled::paint(QPainter* painter, const QStyleOptionGraphicsItem* { if (dir % 2 == 1 && std::abs(a.y() - b.y()) < 2 * br) { - br = std::abs(a.y() - b.y()) / 2; + br = static_cast(std::abs(a.y() - b.y()) / 2); } else if (dir % 2 == 0 && std::abs(a.x() - b.x()) < 2 * br) { - br = std::abs(a.x() - b.x()) / 2; + br = static_cast(std::abs(a.x() - b.x()) / 2); } } diff --git a/src/lib_gui/qt/graphics/base/QtLineItemBase.cpp b/src/lib_gui/qt/graphics/base/QtLineItemBase.cpp index dc0294bf..7163a5c2 100644 --- a/src/lib_gui/qt/graphics/base/QtLineItemBase.cpp +++ b/src/lib_gui/qt/graphics/base/QtLineItemBase.cpp @@ -145,11 +145,11 @@ QPolygon QtLineItemBase::getPath() const Vec2f t[4]; getPivotPoints(t, tR, tR, tOff.y, true); - QPoint a(t[it].x, t[it].y); - QPoint d(o[io].x, o[io].y); + QPoint a(static_cast(t[it].x), static_cast(t[it].y)); + QPoint d(static_cast(o[io].x), static_cast(o[io].y)); - QPoint b(tP[it].x, tP[it].y); - QPoint c(oP[io].x, oP[io].y); + QPoint b(static_cast(tP[it].x), static_cast(tP[it].y)); + QPoint c(static_cast(oP[io].x), static_cast(oP[io].y)); switch (it) { @@ -219,8 +219,8 @@ QPolygon QtLineItemBase::getPath() const { it = (it + 2) % 4; - a = QPoint(t[it].x, t[it].y); - b = QPoint(tP[it].x, tP[it].y); + a = QPoint(static_cast(t[it].x), static_cast(t[it].y)); + b = QPoint(static_cast(tP[it].x), static_cast(tP[it].y)); switch (it) { @@ -242,8 +242,8 @@ QPolygon QtLineItemBase::getPath() const { io = (io + 2) % 4; - d = QPoint(o[io].x, o[io].y); - c = QPoint(oP[io].x, oP[io].y); + d = QPoint(static_cast(o[io].x), static_cast(o[io].y)); + c = QPoint(static_cast(oP[io].x), static_cast(oP[io].y)); switch (io) { @@ -438,9 +438,9 @@ void QtLineItemBase::getPivotPoints( { float f = 1 / 2.f; - p[0] = Vec2f(in.x + (in.z - in.x) * f + offset, out.y); - p[2] = Vec2f(in.x + (in.z - in.x) * f + offset, out.w); + p[0] = Vec2f(static_cast(in.x + (in.z - in.x) * f + offset), static_cast(out.y)); + p[2] = Vec2f(static_cast(in.x + (in.z - in.x) * f + offset), static_cast(out.w)); - p[1] = Vec2f(out.z, in.y + (in.w - in.y) * f + offset); - p[3] = Vec2f(out.x, in.y + (in.w - in.y) * f + offset); + p[1] = Vec2f(static_cast(out.z), static_cast(in.y + (in.w - in.y) * f + offset)); + p[3] = Vec2f(static_cast(out.x), static_cast(in.y + (in.w - in.y) * f + offset)); } diff --git a/src/lib_gui/qt/graphics/component/QtGraphNodeComponentClickable.cpp b/src/lib_gui/qt/graphics/component/QtGraphNodeComponentClickable.cpp index 92450513..8d6fcd1e 100644 --- a/src/lib_gui/qt/graphics/component/QtGraphNodeComponentClickable.cpp +++ b/src/lib_gui/qt/graphics/component/QtGraphNodeComponentClickable.cpp @@ -5,7 +5,7 @@ #include "QtGraphNode.h" QtGraphNodeComponentClickable::QtGraphNodeComponentClickable(QtGraphNode* graphNode) - : QtGraphNodeComponent(graphNode), m_mousePos(0.0f, 0.0f), m_mouseMoved(false) + : QtGraphNodeComponent(graphNode), m_mousePos(0, 0), m_mouseMoved(false) { } @@ -18,7 +18,8 @@ void QtGraphNodeComponentClickable::nodeMousePressEvent(QGraphicsSceneMouseEvent return; } - m_mousePos = Vec2i(event->scenePos().x(), event->scenePos().y()); + m_mousePos = Vec2i( + static_cast(event->scenePos().x()), static_cast(event->scenePos().y())); m_mouseMoved = false; if (event->button() == Qt::MiddleButton) @@ -29,7 +30,8 @@ void QtGraphNodeComponentClickable::nodeMousePressEvent(QGraphicsSceneMouseEvent void QtGraphNodeComponentClickable::nodeMouseMoveEvent(QGraphicsSceneMouseEvent* event) { - Vec2i mousePos = Vec2i(event->scenePos().x(), event->scenePos().y()); + Vec2i mousePos = Vec2i( + static_cast(event->scenePos().x()), static_cast(event->scenePos().y())); if ((mousePos - m_mousePos).getLength() > 3.0f) { diff --git a/src/lib_gui/qt/graphics/component/QtGraphNodeComponentMoveable.cpp b/src/lib_gui/qt/graphics/component/QtGraphNodeComponentMoveable.cpp index 97cb702c..7f8793ef 100644 --- a/src/lib_gui/qt/graphics/component/QtGraphNodeComponentMoveable.cpp +++ b/src/lib_gui/qt/graphics/component/QtGraphNodeComponentMoveable.cpp @@ -5,7 +5,7 @@ #include "QtGraphNode.h" QtGraphNodeComponentMoveable::QtGraphNodeComponentMoveable(QtGraphNode* graphNode) - : QtGraphNodeComponent(graphNode), m_mouseOffset(0.0f, 0.0f) + : QtGraphNodeComponent(graphNode), m_mouseOffset(0, 0) { } @@ -19,16 +19,17 @@ void QtGraphNodeComponentMoveable::nodeMousePressEvent(QGraphicsSceneMouseEvent* } m_oldPos = m_graphNode->getPosition(); - m_mouseOffset.x = event->scenePos().x() - m_oldPos.x; - m_mouseOffset.y = event->scenePos().y() - m_oldPos.y; + m_mouseOffset.x = static_cast(event->scenePos().x() - m_oldPos.x); + m_mouseOffset.y = static_cast(event->scenePos().y() - m_oldPos.y); event->accept(); } void QtGraphNodeComponentMoveable::nodeMouseMoveEvent(QGraphicsSceneMouseEvent* event) { - m_graphNode->setPosition( - Vec2i(event->scenePos().x() - m_mouseOffset.x, event->scenePos().y() - m_mouseOffset.y)); + m_graphNode->setPosition(Vec2i( + static_cast(event->scenePos().x() - m_mouseOffset.x), + static_cast(event->scenePos().y() - m_mouseOffset.y))); event->accept(); } diff --git a/src/lib_gui/qt/graphics/graph/QtGraphEdge.cpp b/src/lib_gui/qt/graphics/graph/QtGraphEdge.cpp index fdf6185c..ca3286c6 100644 --- a/src/lib_gui/qt/graphics/graph/QtGraphEdge.cpp +++ b/src/lib_gui/qt/graphics/graph/QtGraphEdge.cpp @@ -55,7 +55,7 @@ QtGraphEdge::QtGraphEdge( , m_isTrailEdge(false) , m_useBezier(false) , m_isInteractive(isInteractive) - , m_mousePos(0.0f, 0.0f) + , m_mousePos(0, 0) , m_mouseMoved(false) { this->setCursor(Qt::PointingHandCursor); @@ -399,7 +399,7 @@ void QtGraphEdge::focusIn() if (type == Edge::EDGE_AGGREGATION) { - info.count = m_weight; + info.count = static_cast(m_weight); info.countText = "edge"; } info.offset = Vec2i(10, 20); @@ -435,13 +435,15 @@ void QtGraphEdge::focusOut() void QtGraphEdge::mousePressEvent(QGraphicsSceneMouseEvent* event) { - m_mousePos = Vec2i(event->scenePos().x(), event->scenePos().y()); + m_mousePos = Vec2i( + static_cast(event->scenePos().x()), static_cast(event->scenePos().y())); m_mouseMoved = false; } void QtGraphEdge::mouseMoveEvent(QGraphicsSceneMouseEvent* event) { - Vec2i mousePos = Vec2i(event->scenePos().x(), event->scenePos().y()); + Vec2i mousePos = Vec2i( + static_cast(event->scenePos().x()), static_cast(event->scenePos().y())); if ((mousePos - m_mousePos).getLength() > 1.0f) { diff --git a/src/lib_gui/qt/graphics/graph/QtGraphNode.cpp b/src/lib_gui/qt/graphics/graph/QtGraphNode.cpp index dfa1be2d..9702920f 100644 --- a/src/lib_gui/qt/graphics/graph/QtGraphNode.cpp +++ b/src/lib_gui/qt/graphics/graph/QtGraphNode.cpp @@ -95,7 +95,7 @@ const std::list& QtGraphNode::getSubNodes() const Vec2i QtGraphNode::getPosition() const { - return Vec2i(this->scenePos().x(), this->scenePos().y()); + return Vec2i(static_cast(this->scenePos().x()), static_cast(this->scenePos().y())); } bool QtGraphNode::setPosition(const Vec2i& position) @@ -578,7 +578,7 @@ void QtGraphNode::setStyle(const GraphViewStyle::NodeStyle& style) if (!m_icon && !style.iconPath.empty()) { QtDeviceScaledPixmap pixmap(QString::fromStdWString(style.iconPath.wstr())); - pixmap.scaleToHeight(style.iconSize); + pixmap.scaleToHeight(static_cast(style.iconSize)); m_icon = new QGraphicsPixmapItem( utility::colorizePixmap(pixmap.pixmap(), style.color.icon.c_str()), this); @@ -588,7 +588,7 @@ void QtGraphNode::setStyle(const GraphViewStyle::NodeStyle& style) } QFont font(style.fontName.c_str()); - font.setPixelSize(style.fontSize); + font.setPixelSize(static_cast(style.fontSize)); if (style.fontBold) { font.setWeight(QFont::Bold); @@ -596,7 +596,9 @@ void QtGraphNode::setStyle(const GraphViewStyle::NodeStyle& style) m_text->setFont(font); m_text->setBrush(QBrush(style.color.text.c_str())); - m_text->setPos(style.iconOffset.x + style.iconSize + style.textOffset.x, style.textOffset.y); + m_text->setPos( + static_cast(style.iconOffset.x + style.iconSize + style.textOffset.x), + static_cast(style.textOffset.y)); if (m_matchLength) { @@ -605,16 +607,18 @@ void QtGraphNode::setStyle(const GraphViewStyle::NodeStyle& style) m_matchText->setFont(font); m_matchText->setBrush(QBrush(color.text.c_str())); m_matchText->setPos( - style.iconOffset.x + style.iconSize + style.textOffset.x, style.textOffset.y); + static_cast(style.iconOffset.x + style.iconSize + style.textOffset.x), + static_cast(style.textOffset.y)); - float charWidth = + const float charWidth = QFontMetrics(font).width(QStringLiteral("QtGraphNode::QtGraphNode::QtGraphNode")) / 37.0f; - float charHeight = QFontMetrics(font).height(); + const float charHeight = static_cast(QFontMetrics(font).height()); m_matchRect->setRect( - style.iconOffset.x + style.iconSize + style.textOffset.x + m_matchPos * charWidth, - style.textOffset.y, - m_matchLength * charWidth, - charHeight); + static_cast( + style.iconOffset.x + style.iconSize + style.textOffset.x + m_matchPos * charWidth), + static_cast(style.textOffset.y), + static_cast(m_matchLength * charWidth), + static_cast(charHeight)); m_matchRect->setPen(QPen(color.border.c_str())); m_matchRect->setBrush(QBrush(color.fill.c_str())); m_matchRect->setRadius(3); diff --git a/src/lib_gui/qt/graphics/graph/QtGraphNodeAccess.cpp b/src/lib_gui/qt/graphics/graph/QtGraphNodeAccess.cpp index 18e88a49..d94fa472 100644 --- a/src/lib_gui/qt/graphics/graph/QtGraphNodeAccess.cpp +++ b/src/lib_gui/qt/graphics/graph/QtGraphNodeAccess.cpp @@ -87,8 +87,8 @@ void QtGraphNodeAccess::updateStyle() if (m_accessIcon) { m_text->setPos( - style.textOffset.x + m_accessIconSize + 3, - style.textOffset.y + m_accessIconSize - style.fontSize); + static_cast(style.textOffset.x + m_accessIconSize + 3), + static_cast(style.textOffset.y + m_accessIconSize - style.fontSize)); m_accessIcon->setPos(style.textOffset.x, style.textOffset.y); m_accessIcon->setPixmap( @@ -97,7 +97,8 @@ void QtGraphNodeAccess::updateStyle() else { m_text->setPos( - style.textOffset.x, style.textOffset.y + m_accessIconSize + 2 - style.fontSize); + static_cast(style.textOffset.x), + static_cast(style.textOffset.y + m_accessIconSize + 2 - style.fontSize)); } } diff --git a/src/lib_gui/qt/graphics/graph/QtGraphNodeBundle.cpp b/src/lib_gui/qt/graphics/graph/QtGraphNodeBundle.cpp index fb3fd049..e2fe6657 100644 --- a/src/lib_gui/qt/graphics/graph/QtGraphNodeBundle.cpp +++ b/src/lib_gui/qt/graphics/graph/QtGraphNodeBundle.cpp @@ -56,7 +56,8 @@ void QtGraphNodeBundle::updateStyle() } setStyle(style); - Vec2f pos(m_rect->rect().right(), m_rect->rect().top() - 2); + Vec2f pos( + static_cast(m_rect->rect().right()), static_cast(m_rect->rect().top() - 2)); if (m_type.getNodeStyle() == NodeType::STYLE_BIG_NODE) { pos += Vec2f(-2, 2); diff --git a/src/lib_gui/qt/graphics/graph/QtGraphNodeExpandToggle.cpp b/src/lib_gui/qt/graphics/graph/QtGraphNodeExpandToggle.cpp index d09a6c81..3dc9a8a0 100644 --- a/src/lib_gui/qt/graphics/graph/QtGraphNodeExpandToggle.cpp +++ b/src/lib_gui/qt/graphics/graph/QtGraphNodeExpandToggle.cpp @@ -68,9 +68,10 @@ void QtGraphNodeExpandToggle::updateStyle() GraphViewStyle::NodeStyle style = GraphViewStyle::getStyleOfExpandToggleNode(); setStyle(style); - float textX = (m_rect->rect().width() / 2) - - (QFontMetrics(m_text->font()).width(m_text->text()) / 2); - float textY = m_rect->rect().height() / 2 - QFontMetrics(m_text->font()).height() / 1.8f; + float textX = static_cast( + (m_rect->rect().width() / 2) - (QFontMetrics(m_text->font()).width(m_text->text()) / 2)); + const float textY = static_cast( + m_rect->rect().height() / 2 - QFontMetrics(m_text->font()).height() / 1.8f); // move the text to the nearest integer x pos, instead of the next lower int pos // improves results on windows systems diff --git a/src/lib_gui/qt/graphics/graph/QtGraphNodeGroup.cpp b/src/lib_gui/qt/graphics/graph/QtGraphNodeGroup.cpp index c76435c0..cc062460 100644 --- a/src/lib_gui/qt/graphics/graph/QtGraphNodeGroup.cpp +++ b/src/lib_gui/qt/graphics/graph/QtGraphNodeGroup.cpp @@ -40,9 +40,10 @@ QtGraphNodeGroup::QtGraphNodeGroup(Id tokenId, const std::wstring& name, GroupTy GraphViewStyle::NodeStyle style = GraphViewStyle::getStyleOfGroupNode(type, false); GraphViewStyle::NodeMargins margins = GraphViewStyle::getMarginsOfGroupNode(type, true); - int width = style.textOffset.x * 2 + style.borderWidth + margins.charWidth * name.size(); - int height = margins.spacingA + margins.charHeight; - int radius = style.cornerRadius; + const int width = static_cast( + style.textOffset.x * 2 + style.borderWidth + margins.charWidth * name.size()); + const int height = static_cast(margins.spacingA + margins.charHeight); + const int radius = style.cornerRadius; QPainterPath path; path.moveTo(width, 0); diff --git a/src/lib_gui/qt/graphics/graph/QtGraphNodeQualifier.cpp b/src/lib_gui/qt/graphics/graph/QtGraphNodeQualifier.cpp index 18c24042..b2e78614 100644 --- a/src/lib_gui/qt/graphics/graph/QtGraphNodeQualifier.cpp +++ b/src/lib_gui/qt/graphics/graph/QtGraphNodeQualifier.cpp @@ -21,7 +21,7 @@ QtGraphNodeQualifier::QtGraphNodeQualifier(const NameHierarchy& name): m_qualifi QFont font; font.setFamily(GraphViewStyle::getFontNameForDataNode().c_str()); - font.setPixelSize(GraphViewStyle::getFontSizeOfQualifier()); + font.setPixelSize(static_cast(GraphViewStyle::getFontSizeOfQualifier())); font.setWeight(QFont::Normal); m_name = new QGraphicsSimpleTextItem(this); @@ -38,12 +38,12 @@ bool QtGraphNodeQualifier::isQualifierNode() const bool QtGraphNodeQualifier::setPosition(const Vec2i& pos) { - int width = QFontMetrics(m_name->font()).width(m_name->text()) + 10; - int height = QFontMetrics(m_name->font()).height() + 2; - int arrowWidth = height * 0.85; + const int width = QFontMetrics(m_name->font()).width(m_name->text()) + 10; + const int height = QFontMetrics(m_name->font()).height() + 2; + const int arrowWidth = static_cast(height * 0.85); - float smallFactor = 0.5f; - int arrowOffset = arrowWidth * smallFactor; + const float smallFactor = 0.5f; + const int arrowOffset = static_cast(arrowWidth * smallFactor); m_background->setRect( pos.x - width - arrowWidth + arrowOffset, pos.y - height / 2, width, height); @@ -109,12 +109,12 @@ void QtGraphNodeQualifier::updateStyle() void QtGraphNodeQualifier::hoverEnterEvent(QGraphicsSceneHoverEvent* event) { - int width = QFontMetrics(m_name->font()).width(m_name->text()) + 10; - int height = QFontMetrics(m_name->font()).height() + 2; - int arrowWidth = height * 0.85; - float smallFactor = 0.5f; - int arrowOffset = arrowWidth * smallFactor; - int offset = width + arrowWidth - arrowOffset; + const int width = QFontMetrics(m_name->font()).width(m_name->text()) + 10; + const int height = QFontMetrics(m_name->font()).height() + 2; + const int arrowWidth = static_cast(height * 0.85); + const float smallFactor = 0.5f; + const int arrowOffset = static_cast(arrowWidth * smallFactor); + const int offset = width + arrowWidth - arrowOffset; setRect(m_pos.x - offset, m_pos.y - height / 2, width + arrowWidth, height); @@ -141,10 +141,10 @@ void QtGraphNodeQualifier::hoverEnterEvent(QGraphicsSceneHoverEvent* event) void QtGraphNodeQualifier::hoverLeaveEvent(QGraphicsSceneHoverEvent* event) { - int height = QFontMetrics(m_name->font()).height() + 2; - int arrowWidth = height * 0.85; - float smallFactor = 0.5f; - int arrowOffset = arrowWidth * smallFactor; + const int height = QFontMetrics(m_name->font()).height() + 2; + const int arrowWidth = static_cast(height * 0.85); + const float smallFactor = 0.5f; + const int arrowOffset = static_cast(arrowWidth * smallFactor); setRect(m_pos.x - arrowWidth + arrowOffset, m_pos.y - height / 2, arrowWidth, height); diff --git a/src/lib_gui/qt/network/QtTcpWrapper.cpp b/src/lib_gui/qt/network/QtTcpWrapper.cpp index 9ebc84ff..c35a3596 100644 --- a/src/lib_gui/qt/network/QtTcpWrapper.cpp +++ b/src/lib_gui/qt/network/QtTcpWrapper.cpp @@ -1,5 +1,5 @@ #include "QtTcpWrapper.h" -#include "qdatastream.h" +#include #include "logging.h" diff --git a/src/lib_gui/qt/project_wizard/QtProjectWizard.cpp b/src/lib_gui/qt/project_wizard/QtProjectWizard.cpp index f790c22a..99b42ddf 100644 --- a/src/lib_gui/qt/project_wizard/QtProjectWizard.cpp +++ b/src/lib_gui/qt/project_wizard/QtProjectWizard.cpp @@ -120,13 +120,17 @@ void addMsvcCompatibilityFlagsOnDemand(std::shared_ptr void addSourceGroupContents( - QtProjectWizardContentGroup* group, std::shared_ptr settings, QtProjectWizardWindow* window); + QtProjectWizardContentGroup* group, + std::shared_ptr settings, + QtProjectWizardWindow* window); #if BUILD_CXX_LANGUAGE_PACKAGE template <> void addSourceGroupContents( - QtProjectWizardContentGroup* group, std::shared_ptr settings, QtProjectWizardWindow* window) + QtProjectWizardContentGroup* group, + std::shared_ptr settings, + QtProjectWizardWindow* window) { group->addContent(new QtProjectWizardContentCStandard(settings, window)); group->addContent(new QtProjectWizardContentCrossCompilationOptions(settings, window)); @@ -151,12 +155,13 @@ void addSourceGroupContents( group->addContent(new QtProjectWizardContentFlags(settings, window)); group->addContent(new QtProjectWizardContentPathCxxPch(settings, settings, window)); group->addContent(new QtProjectWizardContentCxxPchFlags(settings, window, false)); - } template <> void addSourceGroupContents( - QtProjectWizardContentGroup* group, std::shared_ptr settings, QtProjectWizardWindow* window) + QtProjectWizardContentGroup* group, + std::shared_ptr settings, + QtProjectWizardWindow* window) { group->addContent(new QtProjectWizardContentCppStandard(settings, window)); group->addContent(new QtProjectWizardContentCrossCompilationOptions(settings, window)); @@ -185,10 +190,13 @@ void addSourceGroupContents( template <> void addSourceGroupContents( - QtProjectWizardContentGroup* group, std::shared_ptr settings, QtProjectWizardWindow* window) + QtProjectWizardContentGroup* group, + std::shared_ptr settings, + QtProjectWizardWindow* window) { group->addContent(new QtProjectWizardContentPathCDB(settings, window)); - group->addContent(new QtProjectWizardContentPathsIndexedHeaders(settings, window, "Compilation Database")); + group->addContent( + new QtProjectWizardContentPathsIndexedHeaders(settings, window, "Compilation Database")); group->addContent(new QtProjectWizardContentPathsExclude(settings, window)); group->addSpace(); @@ -210,14 +218,17 @@ void addSourceGroupContents( template <> void addSourceGroupContents( - QtProjectWizardContentGroup* group, std::shared_ptr settings, QtProjectWizardWindow* window) + QtProjectWizardContentGroup* group, + std::shared_ptr settings, + QtProjectWizardWindow* window) { group->addContent(new QtProjectWizardContentCppStandard(settings, window)); group->addContent(new QtProjectWizardContentCStandard(settings, window)); group->addContent(new QtProjectWizardContentPathCodeblocksProject(settings, window)); group->addSpace(); - group->addContent(new QtProjectWizardContentPathsIndexedHeaders(settings, window, "Code::Blocks Project")); + group->addContent( + new QtProjectWizardContentPathsIndexedHeaders(settings, window, "Code::Blocks Project")); group->addContent(new QtProjectWizardContentPathsExclude(settings, window)); group->addContent(new QtProjectWizardContentExtensions(settings, window)); group->addSpace(); @@ -242,7 +253,9 @@ void addSourceGroupContents( template <> void addSourceGroupContents( - QtProjectWizardContentGroup* group, std::shared_ptr settings, QtProjectWizardWindow* window) + QtProjectWizardContentGroup* group, + std::shared_ptr settings, + QtProjectWizardWindow* window) { group->addContent(new QtProjectWizardContentJavaStandard(settings, window)); group->addSpace(); @@ -255,7 +268,9 @@ void addSourceGroupContents( template <> void addSourceGroupContents( - QtProjectWizardContentGroup* group, std::shared_ptr settings, QtProjectWizardWindow* window) + QtProjectWizardContentGroup* group, + std::shared_ptr settings, + QtProjectWizardWindow* window) { group->addContent(new QtProjectWizardContentJavaStandard(settings, window)); group->addContent(new QtProjectWizardContentPathSourceMaven(settings, window)); @@ -267,7 +282,9 @@ void addSourceGroupContents( template <> void addSourceGroupContents( - QtProjectWizardContentGroup* group, std::shared_ptr settings, QtProjectWizardWindow* window) + QtProjectWizardContentGroup* group, + std::shared_ptr settings, + QtProjectWizardWindow* window) { group->addContent(new QtProjectWizardContentJavaStandard(settings, window)); group->addContent(new QtProjectWizardContentPathSourceGradle(settings, window)); @@ -281,7 +298,9 @@ void addSourceGroupContents( template <> void addSourceGroupContents( - QtProjectWizardContentGroup* group, std::shared_ptr settings, QtProjectWizardWindow* window) + QtProjectWizardContentGroup* group, + std::shared_ptr settings, + QtProjectWizardWindow* window) { group->addContent(new QtProjectWizardContentPathPythonEnvironment(settings, window)); group->addContent(new QtProjectWizardContentPathsSource(settings, window)); @@ -293,7 +312,9 @@ void addSourceGroupContents( template <> void addSourceGroupContents( - QtProjectWizardContentGroup* group, std::shared_ptr settings, QtProjectWizardWindow* window) + QtProjectWizardContentGroup* group, + std::shared_ptr settings, + QtProjectWizardWindow* window) { group->addContent(new QtProjectWizardContentCustomCommand(settings, window)); group->addContent(new QtProjectWizardContentPathsSource(settings, window)); @@ -303,7 +324,9 @@ void addSourceGroupContents( template <> void addSourceGroupContents( - QtProjectWizardContentGroup* group, std::shared_ptr settings, QtProjectWizardWindow* window) + QtProjectWizardContentGroup* group, + std::shared_ptr settings, + QtProjectWizardWindow* window) { group->addContent(new QtProjectWizardContentUnloadable(settings, window)); } @@ -661,7 +684,8 @@ void QtProjectWizard::selectedSourceGroupChanged(int index) { addSourceGroupContents(summary, settings, this); } - else if (std::shared_ptr settings = + else if ( + std::shared_ptr settings = std::dynamic_pointer_cast(group)) { addSourceGroupContents(summary, settings, this); @@ -905,11 +929,9 @@ void QtProjectWizard::newSourceGroupFromVS() }); window->resize(QSize(560, 320)); - connect(window, &QtProjectWizardWindow::next, - [this](){ - selectedProjectType(SOURCE_GROUP_CXX_CDB); - } - ); + connect(window, &QtProjectWizardWindow::next, [this]() { + selectedProjectType(SOURCE_GROUP_CXX_CDB); + }); window->show(); window->setNextEnabled(true); @@ -943,12 +965,14 @@ void QtProjectWizard::selectedProjectType(SourceGroupType sourceGroupType) } break; case SOURCE_GROUP_CXX_CDB: - settings = std::make_shared(sourceGroupId, m_projectSettings.get()); + settings = std::make_shared( + sourceGroupId, m_projectSettings.get()); break; case SOURCE_GROUP_CXX_CODEBLOCKS: { std::shared_ptr cxxSettings = - std::make_shared(sourceGroupId, m_projectSettings.get()); + std::make_shared( + sourceGroupId, m_projectSettings.get()); addMsvcCompatibilityFlagsOnDemand(cxxSettings); settings = cxxSettings; } @@ -960,24 +984,29 @@ void QtProjectWizard::selectedProjectType(SourceGroupType sourceGroupType) #if BUILD_JAVA_LANGUAGE_PACKAGE case SOURCE_GROUP_JAVA_EMPTY: - settings = std::make_shared(sourceGroupId, m_projectSettings.get()); + settings = std::make_shared( + sourceGroupId, m_projectSettings.get()); break; case SOURCE_GROUP_JAVA_MAVEN: - settings = std::make_shared(sourceGroupId, m_projectSettings.get()); + settings = std::make_shared( + sourceGroupId, m_projectSettings.get()); break; case SOURCE_GROUP_JAVA_GRADLE: - settings = std::make_shared(sourceGroupId, m_projectSettings.get()); + settings = std::make_shared( + sourceGroupId, m_projectSettings.get()); break; #endif // BUILD_JAVA_LANGUAGE_PACKAGE #if BUILD_PYTHON_LANGUAGE_PACKAGE case SOURCE_GROUP_PYTHON_EMPTY: - settings = std::make_shared(sourceGroupId, m_projectSettings.get()); + settings = std::make_shared( + sourceGroupId, m_projectSettings.get()); break; #endif // BUILD_PYTHON_LANGUAGE_PACKAGE case SOURCE_GROUP_CUSTOM_COMMAND: - settings = std::make_shared(sourceGroupId, m_projectSettings.get()); + settings = std::make_shared( + sourceGroupId, m_projectSettings.get()); break; case SOURCE_GROUP_UNKNOWN: break; @@ -1000,7 +1029,7 @@ void QtProjectWizard::createSourceGroup(std::shared_ptr set m_previouslySelectedIndex = -1; - m_sourceGroupList->setCurrentRow(int(m_allSourceGroupSettings.size()) - 1); + m_sourceGroupList->setCurrentRow(static_cast(m_allSourceGroupSettings.size()) - 1); } void QtProjectWizard::createProject() diff --git a/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCStandard.cpp b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCStandard.cpp index 21922a09..2d63a053 100644 --- a/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCStandard.cpp +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCStandard.cpp @@ -33,7 +33,7 @@ void QtProjectWizardContentCStandard::load() std::vector standards = m_sourceGroupSettings->getAvailableCStandards(); for (size_t i = 0; i < standards.size(); i++) { - m_standard->insertItem(i, QString::fromStdWString(standards[i])); + m_standard->insertItem(static_cast(i), QString::fromStdWString(standards[i])); } m_standard->setCurrentText(QString::fromStdWString(m_sourceGroupSettings->getCStandard())); diff --git a/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCppStandard.cpp b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCppStandard.cpp index b80c7a7e..651ac0e7 100644 --- a/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCppStandard.cpp +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCppStandard.cpp @@ -33,7 +33,7 @@ void QtProjectWizardContentCppStandard::load() std::vector standards = m_sourceGroupSettings->getAvailableCppStandards(); for (size_t i = 0; i < standards.size(); i++) { - m_standard->insertItem(i, QString::fromStdWString(standards[i])); + m_standard->insertItem(static_cast(i), QString::fromStdWString(standards[i])); } m_standard->setCurrentText(QString::fromStdWString(m_sourceGroupSettings->getCppStandard())); diff --git a/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCrossCompilationOptions.cpp b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCrossCompilationOptions.cpp index 571b8206..b28ef86b 100644 --- a/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCrossCompilationOptions.cpp +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentCrossCompilationOptions.cpp @@ -70,7 +70,7 @@ void QtProjectWizardContentCrossCompilationOptions::populate(QGridLayout* layout std::sort(archTypes.begin(), archTypes.end()); for (size_t i = 0; i < archTypes.size(); i++) { - m_arch->insertItem(i, QString::fromStdWString(archTypes[i])); + m_arch->insertItem(static_cast(i), QString::fromStdWString(archTypes[i])); } m_arch->setCurrentIndex(m_arch->findText("x86_64")); @@ -87,7 +87,7 @@ void QtProjectWizardContentCrossCompilationOptions::populate(QGridLayout* layout std::sort(vendorTypes.begin() + 1, vendorTypes.end()); for (size_t i = 0; i < vendorTypes.size(); i++) { - m_vendor->insertItem(i, QString::fromStdWString(vendorTypes[i])); + m_vendor->insertItem(static_cast(i), QString::fromStdWString(vendorTypes[i])); } gridLayout->addWidget(label, 1, 0, Qt::AlignRight); @@ -103,7 +103,7 @@ void QtProjectWizardContentCrossCompilationOptions::populate(QGridLayout* layout std::sort(osTypes.begin() + 1, osTypes.end()); for (size_t i = 0; i < osTypes.size(); i++) { - m_sys->insertItem(i, QString::fromStdWString(osTypes[i])); + m_sys->insertItem(static_cast(i), QString::fromStdWString(osTypes[i])); } gridLayout->addWidget(label, 2, 0, Qt::AlignRight); @@ -119,7 +119,7 @@ void QtProjectWizardContentCrossCompilationOptions::populate(QGridLayout* layout std::sort(environmentTypes.begin() + 1, environmentTypes.end()); for (size_t i = 0; i < environmentTypes.size(); i++) { - m_abi->insertItem(i, QString::fromStdWString(environmentTypes[i])); + m_abi->insertItem(static_cast(i), QString::fromStdWString(environmentTypes[i])); } gridLayout->addWidget(label, 3, 0, Qt::AlignRight); diff --git a/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentPreferences.cpp b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentPreferences.cpp index d821483a..a0a32ac4 100644 --- a/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentPreferences.cpp +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentPreferences.cpp @@ -90,7 +90,8 @@ void QtProjectWizardContentPreferences::populate(QGridLayout* layout, int& row) for (size_t i = 0; i < m_colorSchemePaths.size(); i++) { m_colorSchemes->insertItem( - i, QString::fromStdWString(m_colorSchemePaths[i].withoutExtension().fileName())); + static_cast(i), + QString::fromStdWString(m_colorSchemePaths[i].withoutExtension().fileName())); } connect( m_colorSchemes, @@ -493,7 +494,7 @@ void QtProjectWizardContentPreferences::load() m_textEncoding->setCurrentText(QString::fromStdString(appSettings->getTextEncoding())); FilePath colorSchemePath = appSettings->getColorSchemePath(); - for (size_t i = 0; i < m_colorSchemePaths.size(); i++) + for (int i = 0; i < static_cast(m_colorSchemePaths.size()); i++) { if (colorSchemePath == m_colorSchemePaths[i]) { @@ -584,7 +585,7 @@ void QtProjectWizardContentPreferences::save() if (m_screenScaleFactor) { - appSettings->setScreenScaleFactor(m_screenScaleFactor->currentData().toDouble()); + appSettings->setScreenScaleFactor(m_screenScaleFactor->currentData().toFloat()); } float scrollSpeed = m_scrollSpeed->text().toFloat(); diff --git a/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsHeaderSearch.cpp b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsHeaderSearch.cpp index 2a18aefb..fc31858c 100644 --- a/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsHeaderSearch.cpp +++ b/src/lib_gui/qt/project_wizard/content/paths/QtProjectWizardContentPathsHeaderSearch.cpp @@ -208,7 +208,7 @@ void QtProjectWizardContentPathsHeaderSearch::validateIncludesButtonClicked() sourceFilePaths, utility::toSet(indexedFilePaths), utility::toSet(headerSearchPaths), - log2(sourceFilePaths.size()), + static_cast(log2(sourceFilePaths.size())), [&](const float progress) { dialogView->showProgressDialog( L"Processing", @@ -280,7 +280,7 @@ void QtProjectWizardContentPathsHeaderSearch::finishedSelectDetectIncludesRootPa sourceFilePaths, utility::toSet(searchedPaths), utility::toSet(headerSearchPaths), - log2(sourceFilePaths.size()), + static_cast(log2(sourceFilePaths.size())), [&](const float progress) { dialogView->showProgressDialog( L"Processing", diff --git a/src/lib_gui/qt/utility/QtDeviceScaledPixmap.cpp b/src/lib_gui/qt/utility/QtDeviceScaledPixmap.cpp index b65af215..288b37d3 100644 --- a/src/lib_gui/qt/utility/QtDeviceScaledPixmap.cpp +++ b/src/lib_gui/qt/utility/QtDeviceScaledPixmap.cpp @@ -36,13 +36,15 @@ qreal QtDeviceScaledPixmap::height() const void QtDeviceScaledPixmap::scaleToWidth(int width) { - m_pixmap = m_pixmap.scaledToWidth(width * devicePixelRatio(), Qt::SmoothTransformation); + m_pixmap = m_pixmap.scaledToWidth( + static_cast(width * devicePixelRatio()), Qt::SmoothTransformation); m_pixmap.setDevicePixelRatio(devicePixelRatio()); } void QtDeviceScaledPixmap::scaleToHeight(int height) { - m_pixmap = m_pixmap.scaledToHeight(height * devicePixelRatio(), Qt::SmoothTransformation); + m_pixmap = m_pixmap.scaledToHeight( + static_cast(height * devicePixelRatio()), Qt::SmoothTransformation); m_pixmap.setDevicePixelRatio(devicePixelRatio()); } diff --git a/src/lib_gui/qt/utility/QtHighlighter.cpp b/src/lib_gui/qt/utility/QtHighlighter.cpp index fe7fa6e7..cb35cd9b 100644 --- a/src/lib_gui/qt/utility/QtHighlighter.cpp +++ b/src/lib_gui/qt/utility/QtHighlighter.cpp @@ -170,8 +170,8 @@ void QtHighlighter::highlightDocument() QTextDocument* doc = document(); - size_t docStart = 0; - size_t docEnd = 0; + int docStart = 0; + int docEnd = 0; for (int i = 0; i < doc->blockCount(); i++) { docEnd += doc->findBlockByLineNumber(i).length(); diff --git a/src/lib_gui/qt/utility/QtScrollSpeedChangeListener.cpp b/src/lib_gui/qt/utility/QtScrollSpeedChangeListener.cpp index 39931758..da2462e2 100644 --- a/src/lib_gui/qt/utility/QtScrollSpeedChangeListener.cpp +++ b/src/lib_gui/qt/utility/QtScrollSpeedChangeListener.cpp @@ -31,6 +31,6 @@ void QtScrollSpeedChangeListener::doChangeScrollSpeed(float scrollSpeed) { if (m_scrollBar) { - m_scrollBar->setSingleStep(std::ceil(m_singleStep * scrollSpeed)); + m_scrollBar->setSingleStep(static_cast(std::ceil(m_singleStep * scrollSpeed))); } } diff --git a/src/lib_gui/qt/utility/QtWindowsTaskbarButton.cpp b/src/lib_gui/qt/utility/QtWindowsTaskbarButton.cpp index b929a14f..e0cea997 100644 --- a/src/lib_gui/qt/utility/QtWindowsTaskbarButton.cpp +++ b/src/lib_gui/qt/utility/QtWindowsTaskbarButton.cpp @@ -29,7 +29,8 @@ void QtWindowsTaskbarButton::setProgress(float progress) if (m_taskbarProgress != nullptr) { m_taskbarProgress->show(); - m_taskbarProgress->setValue(std::max(0, std::min(100, 100 * progress))); + m_taskbarProgress->setValue( + static_cast(std::max(0, std::min(100, static_cast(100 * progress))))); } #endif } diff --git a/src/lib_gui/qt/utility/utilityQt.cpp b/src/lib_gui/qt/utility/utilityQt.cpp index 2f7b0dbc..4763cd79 100644 --- a/src/lib_gui/qt/utility/utilityQt.cpp +++ b/src/lib_gui/qt/utility/utilityQt.cpp @@ -99,37 +99,37 @@ std::string getStyleSheet(const FilePath& path) if (val.find("font_size") != std::string::npos) { // check for modifier - if (val.find("+") != std::string::npos) + if (val.find('+') != std::string::npos) { - int pos = val.find("+"); - std::string sub = val.substr(pos + 1); + const size_t findPos = val.find('+'); + std::string sub = val.substr(findPos + 1); int mod = std::stoi(sub); val = std::to_string(ApplicationSettings::getInstance()->getFontSize() + mod); } - else if (val.find("-") != std::string::npos) + else if (val.find('-') != std::string::npos) { - int pos = val.find("-"); - std::string sub = val.substr(pos + 1); + const size_t findPos = val.find('-'); + std::string sub = val.substr(findPos + 1); int mod = std::stoi(sub); val = std::to_string(ApplicationSettings::getInstance()->getFontSize() - mod); } - else if (val.find("*") != std::string::npos) + else if (val.find('*') != std::string::npos) { - int pos = val.find("*"); - std::string sub = val.substr(pos + 1); + const size_t findPos = val.find('*'); + std::string sub = val.substr(findPos + 1); int mod = std::stoi(sub); val = std::to_string(ApplicationSettings::getInstance()->getFontSize() * mod); } - else if (val.find("/") != std::string::npos) + else if (val.find('/') != std::string::npos) { - int pos = val.find("/"); - std::string sub = val.substr(pos + 1); + const size_t findPos = val.find('/'); + std::string sub = val.substr(findPos + 1); int mod = std::stoi(sub); @@ -151,7 +151,7 @@ std::string getStyleSheet(const FilePath& path) size_t index = 0; while (true) { - index = val.find("\\", index); + index = val.find('\\', index); if (index == std::string::npos) { break; diff --git a/src/lib_gui/qt/view/QtErrorView.cpp b/src/lib_gui/qt/view/QtErrorView.cpp index cdd26f02..b6127fc0 100644 --- a/src/lib_gui/qt/view/QtErrorView.cpp +++ b/src/lib_gui/qt/view/QtErrorView.cpp @@ -70,7 +70,8 @@ QtErrorView::QtErrorView(ViewLayout* viewLayout) return; } - const Id errorId = m_model->item(index.row(), Column::ID)->text().toLongLong(); + const Id errorId = static_cast( + m_model->item(index.row(), Column::ID)->text().toLongLong()); m_controllerProxy.executeAsTaskWithArgs(&ErrorController::showError, errorId); } diff --git a/src/lib_gui/qt/view/QtGraphView.cpp b/src/lib_gui/qt/view/QtGraphView.cpp index 8ce6ef89..988bf382 100644 --- a/src/lib_gui/qt/view/QtGraphView.cpp +++ b/src/lib_gui/qt/view/QtGraphView.cpp @@ -363,7 +363,8 @@ void QtGraphView::rebuildGraph( // move graph to center QPointF center = itemsBoundingRect(m_nodes).center(); - Vec2i o = GraphViewStyle::alignOnRaster(Vec2i(center.x(), center.y())); + const Vec2i o = GraphViewStyle::alignOnRaster( + Vec2i(static_cast(center.x()), static_cast(center.y()))); QPointF offset = QPointF(o.x, o.y); m_sceneRectOffset = offset - center; @@ -503,8 +504,10 @@ Vec2i QtGraphView::getViewSize() const { QtGraphicsView* view = getView(); - float zoomFactor = view->getZoomFactor(); - return Vec2i((view->width() - 50) / zoomFactor, (view->height() - 100) / zoomFactor); + const float zoomFactor = view->getZoomFactor(); + return Vec2i( + static_cast((view->width() - 50) / zoomFactor), + static_cast((view->height() - 100) / zoomFactor)); } GroupType QtGraphView::getGrouping() const @@ -1006,7 +1009,7 @@ QtGraphNode* QtGraphView::createNodeRecursive( } else if (node->isExpandToggleNode()) { - newNode = new QtGraphNodeExpandToggle(node->isExpanded(), node->invisibleSubNodeCount); + newNode = new QtGraphNodeExpandToggle(node->isExpanded(), static_cast(node->invisibleSubNodeCount)); } else if (node->isBundleNode()) { @@ -1107,10 +1110,10 @@ QtGraphEdge* QtGraphView::createEdge( std::vector path = edge->path; for (size_t i = 0; i < path.size(); i++) { - path[i].x = path[i].x - pathOffset.x(); - path[i].z = path[i].z - pathOffset.x(); - path[i].y = path[i].y - pathOffset.y(); - path[i].w = path[i].w - pathOffset.y(); + path[i].x = static_cast(path[i].x - pathOffset.x()); + path[i].z = static_cast(path[i].z - pathOffset.x()); + path[i].y = static_cast(path[i].y - pathOffset.y()); + path[i].w = static_cast(path[i].w - pathOffset.y()); } for (const Vec4i& rect: path) diff --git a/src/lib_gui/qt/view/QtGraphViewStyleImpl.cpp b/src/lib_gui/qt/view/QtGraphViewStyleImpl.cpp index 022c3d13..4bb1746b 100644 --- a/src/lib_gui/qt/view/QtGraphViewStyleImpl.cpp +++ b/src/lib_gui/qt/view/QtGraphViewStyleImpl.cpp @@ -15,7 +15,7 @@ float QtGraphViewStyleImpl::getCharWidth(const std::string& fontName, size_t fon float QtGraphViewStyleImpl::getCharHeight(const std::string& fontName, size_t fontSize) { - return QFontMetrics(getFontForStyleType(fontName, fontSize)).height(); + return static_cast(QFontMetrics(getFontForStyleType(fontName, fontSize)).height()); } float QtGraphViewStyleImpl::getGraphViewZoomDifferenceForPlatform() @@ -31,6 +31,6 @@ float QtGraphViewStyleImpl::getGraphViewZoomDifferenceForPlatform() QFont QtGraphViewStyleImpl::getFontForStyleType(const std::string& fontName, size_t fontSize) const { QFont font(fontName.c_str()); - font.setPixelSize(fontSize); + font.setPixelSize(static_cast(fontSize)); return font; } diff --git a/src/lib_gui/qt/view/QtTabsView.cpp b/src/lib_gui/qt/view/QtTabsView.cpp index 1fbd8aef..27f1b7a6 100644 --- a/src/lib_gui/qt/view/QtTabsView.cpp +++ b/src/lib_gui/qt/view/QtTabsView.cpp @@ -137,12 +137,13 @@ void QtTabsView::addTab() void QtTabsView::insertTab(bool showTab, const SearchMatch& match) { - int tabId = TabId::nextTab(); + int tabId = static_cast(TabId::nextTab()); m_tabBar->blockSignals(true); m_insertedTabCount++; - int idx = match.isValid() ? m_tabBar->currentIndex() + m_insertedTabCount : m_tabBar->count() + 1; + int idx = match.isValid() ? static_cast(m_tabBar->currentIndex() + m_insertedTabCount) + : m_tabBar->count() + 1; idx = m_tabBar->insertTab(idx, QStringLiteral(" Empty Tab ")); m_tabBar->setTabData(idx, QVariant(tabId)); diff --git a/src/lib_gui/qt/window/QtAbout.cpp b/src/lib_gui/qt/window/QtAbout.cpp index ed371a17..7ee87cbd 100644 --- a/src/lib_gui/qt/window/QtAbout.cpp +++ b/src/lib_gui/qt/window/QtAbout.cpp @@ -35,7 +35,8 @@ void QtAbout::setupAbout() sourcetrailLogo.scaleToHeight(150); QLabel* sourcetrailLogoLabel = new QLabel(this); sourcetrailLogoLabel->setPixmap(sourcetrailLogo.pixmap()); - sourcetrailLogoLabel->resize(sourcetrailLogo.width(), sourcetrailLogo.height()); + sourcetrailLogoLabel->resize( + static_cast(sourcetrailLogo.width()), static_cast(sourcetrailLogo.height())); windowLayout->addWidget( sourcetrailLogoLabel, 0, Qt::Alignment(Qt::AlignmentFlag::AlignHCenter)); } diff --git a/src/lib_gui/qt/window/QtIndexingDialog.cpp b/src/lib_gui/qt/window/QtIndexingDialog.cpp index 448e75fe..1e957c6e 100644 --- a/src/lib_gui/qt/window/QtIndexingDialog.cpp +++ b/src/lib_gui/qt/window/QtIndexingDialog.cpp @@ -65,7 +65,7 @@ QLabel* QtIndexingDialog::createFlagLabel(QWidget* parent) QLabel* flagLabel = new QLabel(parent); flagLabel->setPixmap(flag.pixmap()); - flagLabel->resize(flag.width(), flag.height()); + flagLabel->resize(static_cast(flag.width()), static_cast(flag.height())); flagLabel->move(15, 75); flagLabel->show(); diff --git a/src/lib_gui/qt/window/QtIndexingProgressDialog.cpp b/src/lib_gui/qt/window/QtIndexingProgressDialog.cpp index d0534caa..77f26cb4 100644 --- a/src/lib_gui/qt/window/QtIndexingProgressDialog.cpp +++ b/src/lib_gui/qt/window/QtIndexingProgressDialog.cpp @@ -6,7 +6,7 @@ #include "MessageIndexingInterrupted.h" QtIndexingProgressDialog::QtIndexingProgressDialog(bool hideable, QWidget* parent) - : QtProgressBarDialog(0.38, true, parent), m_filePathLabel(nullptr), m_errorWidget(nullptr) + : QtProgressBarDialog(0.38f, true, parent), m_filePathLabel(nullptr), m_errorWidget(nullptr) { setSizeGripStyle(false); @@ -57,7 +57,7 @@ void QtIndexingProgressDialog::updateIndexingProgress( QString::number(fileCount) + "/" + QString::number(totalFileCount) + " File" + (totalFileCount > 1 ? "s" : "")); - int progress = 0; + size_t progress = 0; if (totalFileCount > 0) { progress = fileCount * 100 / totalFileCount; diff --git a/src/lib_gui/qt/window/QtProgressBarDialog.cpp b/src/lib_gui/qt/window/QtProgressBarDialog.cpp index c8794d47..bf255ed9 100644 --- a/src/lib_gui/qt/window/QtProgressBarDialog.cpp +++ b/src/lib_gui/qt/window/QtProgressBarDialog.cpp @@ -94,18 +94,25 @@ void QtProgressBarDialog::setGeometries() if (m_top) { QMargins margins = m_content->layout()->contentsMargins(); - margins.setTop(m_window->size().height() * m_topRatio + 10); + margins.setTop(static_cast(m_window->size().height() * m_topRatio + 10)); m_content->layout()->setContentsMargins(margins); - m_top->setGeometry(0, 0, m_window->size().width(), m_window->size().height() * m_topRatio); + m_top->setGeometry( + 0, 0, m_window->size().width(), static_cast(m_window->size().height() * m_topRatio)); m_title->setGeometry( - 45, m_window->size().height() * m_topRatio - 50, m_window->size().width() - 60, 40); + 45, + static_cast(m_window->size().height() * m_topRatio - 50), + m_window->size().width() - 60, + 40); } if (m_progressBar) { m_progressBar->setGeometry( - 0, m_window->size().height() * m_topRatio - 5, m_window->size().width(), 10); + 0, + static_cast(m_window->size().height() * m_topRatio - 5), + m_window->size().width(), + 10); } } diff --git a/src/lib_gui/qt/window/QtWindow.cpp b/src/lib_gui/qt/window/QtWindow.cpp index aae0f9be..d8fb4e40 100644 --- a/src/lib_gui/qt/window/QtWindow.cpp +++ b/src/lib_gui/qt/window/QtWindow.cpp @@ -351,7 +351,8 @@ void QtWindow::addLogo() QLabel* sourcetrailLogoLabel = new QLabel(this); sourcetrailLogoLabel->setPixmap(sourcetrailLogo.pixmap()); - sourcetrailLogoLabel->resize(sourcetrailLogo.width(), sourcetrailLogo.height()); + sourcetrailLogoLabel->resize( + static_cast(sourcetrailLogo.width()), static_cast(sourcetrailLogo.height())); sourcetrailLogoLabel->move(m_isSubWindow ? 40 : 23, 25); sourcetrailLogoLabel->show(); diff --git a/src/lib_gui/utility/path_detector/java_runtime/JavaPathDetectorLinux.cpp b/src/lib_gui/utility/path_detector/java_runtime/JavaPathDetectorLinux.cpp index de4d7cee..a581a01e 100644 --- a/src/lib_gui/utility/path_detector/java_runtime/JavaPathDetectorLinux.cpp +++ b/src/lib_gui/utility/path_detector/java_runtime/JavaPathDetectorLinux.cpp @@ -60,8 +60,10 @@ FilePath JavaPathDetectorLinux::getFilePathRelativeToJavaExecutable(FilePath& ja FilePath JavaPathDetectorLinux::getJavaInJavaHome() const { std::string command = ""; - +#pragma warning(push) +#pragma warning(disable : 4996) char* p = getenv("JAVA_HOME"); +#pragma warning(pop) if (p == nullptr) { return FilePath(); diff --git a/src/lib_java/utility/utilityJava.cpp b/src/lib_java/utility/utilityJava.cpp index 8166bf3e..a024bc2b 100644 --- a/src/lib_java/utility/utilityJava.cpp +++ b/src/lib_java/utility/utilityJava.cpp @@ -188,7 +188,10 @@ std::vector getClassPath( void setJavaHomeVariableIfNotExists() { +#pragma warning(push) +#pragma warning(disable : 4996) if (getenv("JAVA_HOME") == nullptr) +#pragma warning(pop) { const FilePath javaPath = ApplicationSettings::getInstance()->getJavaPath(); const FilePath javaHomePath = @@ -197,8 +200,10 @@ void setJavaHomeVariableIfNotExists() LOG_WARNING( "Environment variable \"JAVA_HOME\" not found on system. Setting value to \"" + javaHomePath.str() + "\" for this process."); - +#pragma warning(push) +#pragma warning(disable : 4996) putenv(const_cast(("JAVA_HOME=" + javaHomePath.str()).c_str())); +#pragma warning(pop) } } } // namespace utility diff --git a/src/lib_utility/utility/utilityString.cpp b/src/lib_utility/utility/utilityString.cpp index 19604878..e127527f 100644 --- a/src/lib_utility/utility/utilityString.cpp +++ b/src/lib_utility/utility/utilityString.cpp @@ -627,8 +627,9 @@ bool caseInsensitiveLess(const std::wstring& s1, const std::wstring& s2) { size_t s1_size = s1.size(); size_t s2_size = s2.size(); - bool res_cmp = s1_size < s2_size; - size_t lesser_size = s2_size ^ ((s1_size ^ s2_size) & -res_cmp); + bool res_cmp = s1_size < s2_size; + size_t lesser_size = s2_size ^ + ((s1_size ^ s2_size) & static_cast(-static_cast(res_cmp))); for (size_t i = 0; i < lesser_size; ++i) { wchar_t s1_wchr = s1[i]; diff --git a/src/test/CommandlineTestSuite.cpp b/src/test/CommandlineTestSuite.cpp index 28dee0c7..b71373e3 100644 --- a/src/test/CommandlineTestSuite.cpp +++ b/src/test/CommandlineTestSuite.cpp @@ -87,7 +87,7 @@ TEST_CASE("command line") parser.parse(); bool processes = ApplicationSettings::getInstance()->getMultiProcessIndexingEnabled(); - REQUIRE(processes == 0); + REQUIRE(processes == false); std::vector args1({"config", "--use-processes", "true"}); @@ -95,7 +95,7 @@ TEST_CASE("command line") parser.parse(); processes = ApplicationSettings::getInstance()->getMultiProcessIndexingEnabled(); - REQUIRE(processes == 1); + REQUIRE(processes == true); } ApplicationSettings::getInstance()->load(appSettingsPath); diff --git a/src/test/MatrixBaseTestSuite.cpp b/src/test/MatrixBaseTestSuite.cpp index c9204157..3b0690c0 100644 --- a/src/test/MatrixBaseTestSuite.cpp +++ b/src/test/MatrixBaseTestSuite.cpp @@ -41,9 +41,9 @@ Array3x5 getTestValues3x5_b() { Array3x5 result; - for (unsigned int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { - for (unsigned int j = 0; j < 5; j++) + for (int j = 0; j < 5; j++) { result.array[i][j] = -i - j; } @@ -197,6 +197,8 @@ TEST_CASE("matrixBase multiplyDivideScalar") { MatrixBase matrix0 = getTestMatrix3x5(); +#pragma warning(push) +#pragma warning(disable : 4244) matrix0.scalarMultiplication(2.0f); // float is on porpoise (so is porpoise, womp womp) REQUIRE(0 == matrix0.getValue(0, 0)); @@ -220,6 +222,7 @@ TEST_CASE("matrixBase multiplyDivideScalar") REQUIRE(0 == matrix0.getValue(0, 0)); REQUIRE(0 == matrix0.getValue(1, 1)); REQUIRE(1 == matrix0.getValue(2, 2)); +#pragma warning(pop) } TEST_CASE("matrixBase multiplyMatrix") diff --git a/src/test/SharedMemoryTestSuite.cpp b/src/test/SharedMemoryTestSuite.cpp index 9bb6012a..4220e064 100644 --- a/src/test/SharedMemoryTestSuite.cpp +++ b/src/test/SharedMemoryTestSuite.cpp @@ -38,7 +38,7 @@ TEST_CASE("shared memory") SharedMemory::Vector* nums = access.accessValueWithAllocator>("nums"); - nums->push_back(nums->size()); + nums->push_back(static_cast(nums->size())); SharedMemory::Vector* strings = access.accessValueWithAllocator>( @@ -47,7 +47,8 @@ TEST_CASE("shared memory") SharedMemory::Map* vals = access.accessValueWithAllocator>("vals"); - vals->emplace(vals->size(), vals->size() * vals->size()); + vals->emplace( + static_cast(vals->size()), static_cast(vals->size() * vals->size())); })); } diff --git a/src/test/SourceGroupTestSuite.cpp b/src/test/SourceGroupTestSuite.cpp index 72cc3f05..e7a25b03 100644 --- a/src/test/SourceGroupTestSuite.cpp +++ b/src/test/SourceGroupTestSuite.cpp @@ -240,7 +240,7 @@ void generateAndCompareExpectedOutput( expectedOutput->getLineCount() == output->getLineCount()); if (expectedOutput->getLineCount() == output->getLineCount()) { - for (size_t i = 1; i <= expectedOutput->getLineCount(); i++) + for (unsigned int i = 1; i <= expectedOutput->getLineCount(); i++) { REQUIRE(expectedOutput->getLine(i) == output->getLine(i)); } diff --git a/src/test/SqliteBookmarkStorageTestSuite.cpp b/src/test/SqliteBookmarkStorageTestSuite.cpp index 150a5637..dde4fc14 100644 --- a/src/test/SqliteBookmarkStorageTestSuite.cpp +++ b/src/test/SqliteBookmarkStorageTestSuite.cpp @@ -21,7 +21,7 @@ TEST_CASE("add bookmarks") L"test bookmark", L"test comment", TimeStamp::now().toString(), categoryId)); } - result = storage.getAllBookmarks().size(); + result = static_cast(storage.getAllBookmarks().size()); } FileSystem::remove(databasePath); @@ -52,7 +52,7 @@ TEST_CASE("add bookmarked node") storage.addBookmarkedNode(StorageBookmarkedNodeData(bookmarkId, L"test name")); } - result = storage.getAllBookmarkedNodes().size(); + result = static_cast(storage.getAllBookmarkedNodes().size()); } FileSystem::remove(databasePath); @@ -80,7 +80,7 @@ TEST_CASE("remove bookmark also removes bookmarked node") storage.removeBookmark(bookmarkId); - result = storage.getAllBookmarkedNodes().size(); + result = static_cast(storage.getAllBookmarkedNodes().size()); } FileSystem::remove(databasePath); diff --git a/src/test/SqliteIndexStorageTestSuite.cpp b/src/test/SqliteIndexStorageTestSuite.cpp index 58403560..4a1ac504 100644 --- a/src/test/SqliteIndexStorageTestSuite.cpp +++ b/src/test/SqliteIndexStorageTestSuite.cpp @@ -28,7 +28,7 @@ TEST_CASE("storage removes node successfully") SqliteIndexStorage storage(databasePath); storage.setup(); storage.beginTransaction(); - int nodeId = storage.addNode(StorageNodeData(0, L"a")); + Id nodeId = storage.addNode(StorageNodeData(0, L"a")); storage.removeElement(nodeId); storage.commitTransaction(); nodeCount = storage.getNodeCount(); @@ -46,8 +46,8 @@ TEST_CASE("storage adds edge successfully") SqliteIndexStorage storage(databasePath); storage.setup(); storage.beginTransaction(); - int sourceNodeId = storage.addNode(StorageNodeData(0, L"a")); - int targetNodeId = storage.addNode(StorageNodeData(0, L"b")); + Id sourceNodeId = storage.addNode(StorageNodeData(0, L"a")); + Id targetNodeId = storage.addNode(StorageNodeData(0, L"b")); storage.addEdge(StorageEdgeData(0, sourceNodeId, targetNodeId)); storage.commitTransaction(); edgeCount = storage.getEdgeCount(); @@ -65,9 +65,9 @@ TEST_CASE("storage removes edge successfully") SqliteIndexStorage storage(databasePath); storage.setup(); storage.beginTransaction(); - int sourceNodeId = storage.addNode(StorageNodeData(0, L"a")); - int targetNodeId = storage.addNode(StorageNodeData(0, L"b")); - int edgeId = storage.addEdge(StorageEdgeData(0, sourceNodeId, targetNodeId)); + Id sourceNodeId = storage.addNode(StorageNodeData(0, L"a")); + Id targetNodeId = storage.addNode(StorageNodeData(0, L"b")); + Id edgeId = storage.addEdge(StorageEdgeData(0, sourceNodeId, targetNodeId)); storage.removeElement(edgeId); storage.commitTransaction(); edgeCount = storage.getEdgeCount(); diff --git a/src/test/Vector2TestSuite.cpp b/src/test/Vector2TestSuite.cpp index 620bb8dc..9a0e91da 100644 --- a/src/test/Vector2TestSuite.cpp +++ b/src/test/Vector2TestSuite.cpp @@ -193,8 +193,11 @@ TEST_CASE("scalar multiplication operators") REQUIRE(-84.0f == vec0.x); REQUIRE(84.0f == vec0.y); +#pragma warning(push) +#pragma warning(disable : 4244) Vec2i vec2(-2, 2); Vec2i vec3 = vec2 * 42.4f; +#pragma warning(pop) REQUIRE(-84 == (int)vec3.x); REQUIRE(84 == (int)vec3.y);