Commit 7f7f5acc authored by Michael Reeves's avatar Michael Reeves

Fix null pointer access detected by clang-tidy, add clang warning flags

parent ebea7ffa
...@@ -53,7 +53,7 @@ set(KDiff3_LIBRARIES ${Qt5PrintSupport_LIBRARIES} KF5::I18n KF5::CoreAddons KF5: ...@@ -53,7 +53,7 @@ set(KDiff3_LIBRARIES ${Qt5PrintSupport_LIBRARIES} KF5::I18n KF5::CoreAddons KF5:
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# I don't need warnings about wired things in comments. # I don't need warnings about wired things in comments.
set(CLANG_WARNING_FLAGS "-Wno-comment -Wshorten-64-to-32") set(CLANG_WARNING_FLAGS "-Wno-comment -Wshorten-64-to-32 -Wstring-conversion -Wc++11-narrowing")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CLANG_WARNING_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CLANG_WARNING_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CLANG_WARNING_FLAGS}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CLANG_WARNING_FLAGS}")
endif() endif()
......
...@@ -1232,7 +1232,8 @@ QString DiffTextWindowData::getString(int d3lIdx) ...@@ -1232,7 +1232,8 @@ QString DiffTextWindowData::getString(int d3lIdx)
DiffList* pFineDiff2; DiffList* pFineDiff2;
int changed = 0; int changed = 0;
int changed2 = 0; int changed2 = 0;
int lineIdx; int lineIdx = -1;
getLineInfo(*d3l, lineIdx, pFineDiff1, pFineDiff2, changed, changed2); getLineInfo(*d3l, lineIdx, pFineDiff1, pFineDiff2, changed, changed2);
if(lineIdx == -1) if(lineIdx == -1)
......
...@@ -2473,10 +2473,11 @@ void KDiff3App::slotUpdateAvailabilities() ...@@ -2473,10 +2473,11 @@ void KDiff3App::slotUpdateAvailabilities()
dirShowBoth->setEnabled(m_bDirCompare); dirShowBoth->setEnabled(m_bDirCompare);
dirViewToggle->setEnabled( dirViewToggle->setEnabled(
m_bDirCompare && m_bDirCompare &&
((!m_pDirectoryMergeSplitter->isVisible() && m_pMainWidget != nullptr && m_pMainWidget->isVisible()) || ((m_pDirectoryMergeSplitter != nullptr && m_pMainWidget != nullptr) &&
(m_pDirectoryMergeSplitter->isVisible() && m_pMainWidget != nullptr && !m_pMainWidget->isVisible() && bTextDataAvailable))); ((!m_pDirectoryMergeSplitter->isVisible() && m_pMainWidget->isVisible()) ||
(m_pDirectoryMergeSplitter->isVisible() && !m_pMainWidget->isVisible() && bTextDataAvailable))));
bool bDirWindowHasFocus = m_pDirectoryMergeSplitter->isVisible() && m_pDirectoryMergeWindow->hasFocus(); bool bDirWindowHasFocus = m_pDirectoryMergeSplitter != nullptr && m_pDirectoryMergeSplitter->isVisible() && m_pDirectoryMergeWindow->hasFocus();
showWhiteSpaceCharacters->setEnabled(bDiffWindowVisible); showWhiteSpaceCharacters->setEnabled(bDiffWindowVisible);
autoAdvance->setEnabled(bMergeEditorVisible); autoAdvance->setEnabled(bMergeEditorVisible);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment