From bdcc386a3a4a8d79b0b60f473ecd0acfa597b930 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Sun, 29 Oct 2017 17:57:06 +0200 Subject: [PATCH] Fix static analyzer issue "An exception should be caught by reference" V746 Object slicing. An exception should be caught by reference rather than by value. filedialog.cpp 183 V746 Object slicing. An exception should be caught by reference rather than by value. nppbigswitch.cpp 110 V746 Object slicing. An exception should be caught by reference rather than by value. pluginsmanager.cpp 259 --- .../src/MISC/PluginsManager/PluginsManager.cpp | 12 ++++++------ PowerEditor/src/NppBigSwitch.cpp | 2 +- .../WinControls/OpenSaveFileDialog/FileDialog.cpp | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp index 4e5fc3d64..5cfb363de 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp @@ -256,7 +256,7 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector(_pluginInfos.size() - 1); } - catch (std::exception e) + catch (std::exception& e) { ::MessageBoxA(NULL, e.what(), "Exception", MB_OK); return -1; @@ -519,7 +519,7 @@ void PluginsManager::runPluginCommand(size_t i) { _pluginsCommands[i]._pFunc(); } - catch (std::exception e) + catch (std::exception& e) { ::MessageBoxA(NULL, e.what(), "PluginsManager::runPluginCommand Exception", MB_OK); } @@ -546,7 +546,7 @@ void PluginsManager::runPluginCommand(const TCHAR *pluginName, int commandID) { _pluginsCommands[i]._pFunc(); } - catch (std::exception e) + catch (std::exception& e) { ::MessageBoxA(NULL, e.what(), "Exception", MB_OK); } @@ -575,7 +575,7 @@ void PluginsManager::notify(const SCNotification *notification) { _pluginInfos[i]->_pBeNotified(&scNotif); } - catch (std::exception e) + catch (std::exception& e) { ::MessageBoxA(NULL, e.what(), "Exception", MB_OK); } @@ -601,7 +601,7 @@ void PluginsManager::relayNppMessages(UINT Message, WPARAM wParam, LPARAM lParam { _pluginInfos[i]->_pMessageProc(Message, wParam, lParam); } - catch (std::exception e) + catch (std::exception& e) { ::MessageBoxA(NULL, e.what(), "Exception", MB_OK); } @@ -632,7 +632,7 @@ bool PluginsManager::relayPluginMessages(UINT Message, WPARAM wParam, LPARAM lPa { _pluginInfos[i]->_pMessageProc(Message, wParam, lParam); } - catch (std::exception e) + catch (std::exception& e) { ::MessageBoxA(NULL, e.what(), "Exception", MB_OK); } diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index a69c397c1..f4d95c363 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -107,7 +107,7 @@ LRESULT Notepad_plus_Window::runProc(HWND hwnd, UINT message, WPARAM wParam, LPA _notepad_plus_plus_core._pPublicInterface = this; return _notepad_plus_plus_core.init(hwnd); } - catch (std::exception ex) + catch (std::exception& ex) { ::MessageBoxA(hwnd, ex.what(), "Exception On WM_CREATE", MB_OK); exit(-1); diff --git a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp index 03cddaf49..9e823d561 100644 --- a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp +++ b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp @@ -180,7 +180,7 @@ TCHAR* FileDialog::doOpenSingleFileDlg() ::GetCurrentDirectory(MAX_PATH, dir); params->setWorkingDir(dir); } - } catch(std::exception e) { + } catch(std::exception& e) { ::MessageBoxA(NULL, e.what(), "Exception", MB_OK); } catch(...) { ::MessageBox(NULL, TEXT("doOpenSingleFileDlg crashes!!!"), TEXT(""), MB_OK); @@ -268,7 +268,7 @@ TCHAR * FileDialog::doSaveDlg() ::GetCurrentDirectory(MAX_PATH, dir); params->setWorkingDir(dir); } - } catch(std::exception e) { + } catch(std::exception& e) { ::MessageBoxA(NULL, e.what(), "Exception", MB_OK); } catch(...) { ::MessageBox(NULL, TEXT("GetSaveFileName crashes!!!"), TEXT(""), MB_OK);