mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-03 09:46:54 +02:00
Fix cppcheck reported issues (#333)
Fixes: https://github.com/microsoft/PowerToys/issues/266
This commit is contained in:
committed by
GitHub
parent
12cd7bb49f
commit
8ac6db8b5a
@@ -142,7 +142,7 @@ public:
|
||||
MessageBox(NULL, msg.c_str(), L"Custom action call.", MB_OK | MB_TOPMOST);
|
||||
}
|
||||
}
|
||||
catch (std::exception ex) {
|
||||
catch (std::exception& ex) {
|
||||
// Improper JSON.
|
||||
}
|
||||
}
|
||||
@@ -180,7 +180,7 @@ public:
|
||||
// Otherwise call a custom function to process the settings before saving them to disk:
|
||||
// save_settings();
|
||||
}
|
||||
catch (std::exception ex) {
|
||||
catch (std::exception& ex) {
|
||||
// Improper JSON.
|
||||
}
|
||||
}
|
||||
@@ -221,7 +221,7 @@ void ExamplePowertoy::init_settings() {
|
||||
try {
|
||||
// Load and parse the settings file for this PowerToy.
|
||||
PowerToysSettings::PowerToyValues settings =
|
||||
PowerToysSettings::PowerToyValues::load_from_settings_file(get_name());
|
||||
PowerToysSettings::PowerToyValues::load_from_settings_file(ExamplePowertoy::get_name());
|
||||
|
||||
// Load the bool property.
|
||||
if (settings.is_bool_value(L"test_bool_toggle")) {
|
||||
@@ -243,7 +243,7 @@ void ExamplePowertoy::init_settings() {
|
||||
g_settings.test_color_prop = settings.get_string_value(L"test_color_picker");
|
||||
}
|
||||
}
|
||||
catch (std::exception ex) {
|
||||
catch (std::exception& ex) {
|
||||
// Error while loading from the settings file. Let default values stay as they are.
|
||||
}
|
||||
}
|
||||
@@ -282,7 +282,7 @@ void ExamplePowertoy::save_settings() {
|
||||
// Save the PowerToyValues JSON to the power toy settings file.
|
||||
values.save_to_settings_file();
|
||||
}
|
||||
catch (std::exception ex) {
|
||||
catch (std::exception& ex) {
|
||||
// Couldn't save the settings.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ public:
|
||||
|
||||
FancyZonesModule()
|
||||
{
|
||||
m_settings = MakeFancyZonesSettings(reinterpret_cast<HINSTANCE>(&__ImageBase), get_name());
|
||||
m_settings = MakeFancyZonesSettings(reinterpret_cast<HINSTANCE>(&__ImageBase), FancyZonesModule::get_name());
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -62,14 +62,14 @@ void Trace::FancyZones::ToggleZoneViewers(bool visible) noexcept
|
||||
TraceLoggingBoolean(visible, "Visible"));
|
||||
}
|
||||
|
||||
void Trace::FancyZones::OnKeyDown(DWORD vk, bool win, bool control, bool inMoveSize) noexcept
|
||||
void Trace::FancyZones::OnKeyDown(DWORD vkCode, bool win, bool control, bool inMoveSize) noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
g_hProvider,
|
||||
"FancyZones::Event::OnKeyDown",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE),
|
||||
TraceLoggingValue(vk, "Hotkey"),
|
||||
TraceLoggingValue(vkCode, "Hotkey"),
|
||||
TraceLoggingBoolean(win, "WindowsKey"),
|
||||
TraceLoggingBoolean(control, "ControlKey"),
|
||||
TraceLoggingBoolean(inMoveSize, "InMoveSize"));
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
Mouse
|
||||
};
|
||||
|
||||
static void KeyUp(WPARAM wparam, bool isEditorMode) noexcept;
|
||||
static void KeyUp(WPARAM wParam, bool isEditorMode) noexcept;
|
||||
static void MoveSizeEnd(_In_opt_ winrt::com_ptr<IZoneSet> activeSet) noexcept;
|
||||
static void CycleActiveZoneSet(_In_opt_ winrt::com_ptr<IZoneSet> activeSet, InputMode mode) noexcept;
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ D2D1_RECT_F D2DOverlaySVG::get_snap_right() const {
|
||||
}
|
||||
|
||||
|
||||
D2DOverlayWindow::D2DOverlayWindow() : animation(0.3), total_screen({}) {
|
||||
D2DOverlayWindow::D2DOverlayWindow() : total_screen({}), animation(0.3) {
|
||||
tasklist_thread = std::thread([&] {
|
||||
while (running) {
|
||||
// Removing <std::mutex> causes C3538 on std::unique_lock lock(mutex); in show(..)
|
||||
@@ -443,7 +443,6 @@ void render_arrow(D2DSVG& arrow, TasklistButton& button, RECT window, float max_
|
||||
// assume button is 25% wider than taller, +10% to make room for each of the arrows that are hidden
|
||||
auto render_arrow_width = (int)(button.height * 1.25f * 1.2f);
|
||||
auto render_arrow_height = (int)(render_arrow_width * arrow_ratio);
|
||||
auto y_edge = dy == -1 ? button.y : button.y + button.height;
|
||||
arrow.resize(button.x + (button.width - render_arrow_width) / 2,
|
||||
dy == -1 ? button.y - render_arrow_height : 0,
|
||||
render_arrow_width, render_arrow_height, 0.95f, max_scale)
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
|
||||
private:
|
||||
void animate(int vk_code, int offset);
|
||||
bool show_thumbnail(const RECT& rect_and_scale, double alpha);
|
||||
bool show_thumbnail(const RECT& rect, double alpha);
|
||||
void hide_thumbnail();
|
||||
virtual void init() override;
|
||||
virtual void resize() override;
|
||||
@@ -78,7 +78,7 @@ private:
|
||||
HTHUMBNAIL thumbnail;
|
||||
HWND active_window = nullptr;
|
||||
D2DOverlaySVG landscape, portrait;
|
||||
D2DOverlaySVG* use_overlay;
|
||||
D2DOverlaySVG* use_overlay = nullptr;
|
||||
D2DSVG no_active;
|
||||
std::vector<D2DSVG> arrows;
|
||||
std::chrono::steady_clock::time_point shown_start_time;
|
||||
|
||||
@@ -70,7 +70,7 @@ void OverlayWindow::set_config(const wchar_t * config) {
|
||||
}
|
||||
_values.save_to_settings_file();
|
||||
}
|
||||
catch (std::exception ex) {
|
||||
catch (std::exception&) {
|
||||
// Improper JSON.
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,6 @@ void OverlayWindow::disable() {
|
||||
if (_enabled) {
|
||||
winkey_popup->hide();
|
||||
target_state->exit();
|
||||
int a = 0;
|
||||
delete target_state;
|
||||
delete winkey_popup;
|
||||
target_state = nullptr;
|
||||
@@ -156,7 +155,7 @@ void OverlayWindow::destroy() {
|
||||
void OverlayWindow::init_settings() {
|
||||
try {
|
||||
PowerToysSettings::PowerToyValues settings =
|
||||
PowerToysSettings::PowerToyValues::load_from_settings_file(get_name());
|
||||
PowerToysSettings::PowerToyValues::load_from_settings_file(OverlayWindow::get_name());
|
||||
if (settings.is_int_value(pressTime.name)) {
|
||||
pressTime.value = settings.get_int_value(pressTime.name);
|
||||
}
|
||||
@@ -164,7 +163,7 @@ void OverlayWindow::init_settings() {
|
||||
overlayOpacity.value = settings.get_int_value(overlayOpacity.name);
|
||||
}
|
||||
}
|
||||
catch (std::exception ex) {
|
||||
catch (std::exception&) {
|
||||
// Error while loading from the settings file. Just let default values stay as they are.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ void TargetState::handle_timeout() {
|
||||
std::unique_lock lock(mutex);
|
||||
auto wait_time = delay - (std::chrono::system_clock::now() - winkey_timestamp);
|
||||
if (events.empty())
|
||||
cv.wait_for(lock, delay);
|
||||
cv.wait_for(lock, wait_time);
|
||||
if (state == Exiting)
|
||||
return;
|
||||
while (!events.empty()) {
|
||||
|
||||
Reference in New Issue
Block a user