mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-11-27 14:59:16 +08:00
[Analyzers][CPP] Turn on warning 4458 (#22265)
* Turn on warning 4458 Fix the errors by changing variable names and supressing the warning on winRT GDI headers * explaining the warning disables
This commit is contained in:
parent
21a9c82df4
commit
6a6c45189e
@ -42,7 +42,7 @@
|
||||
<ClCompile>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<DisableSpecificWarnings>26800;28251;6387;4458;4505;4702;6031;6248;26451;28182;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<DisableSpecificWarnings>26800;28251;6387;4505;4702;6031;6248;26451;28182;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<DisableAnalyzeExternal >true</DisableAnalyzeExternal>
|
||||
<ExternalWarningLevel>TurnOffAllWarnings</ExternalWarningLevel>
|
||||
<ConformanceMode>false</ConformanceMode>
|
||||
|
@ -98,11 +98,11 @@ void Logger::init(std::string loggerName, std::wstring logFilePath, std::wstring
|
||||
|
||||
void Logger::init(std::vector<spdlog::sink_ptr> sinks)
|
||||
{
|
||||
auto logger = std::make_shared<spdlog::logger>("", begin(sinks), end(sinks));
|
||||
if (!logger)
|
||||
auto init_logger = std::make_shared<spdlog::logger>("", begin(sinks), end(sinks));
|
||||
if (!init_logger)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Logger::logger = logger;
|
||||
Logger::logger = init_logger;
|
||||
}
|
||||
|
@ -8,16 +8,16 @@ void Animation::reset()
|
||||
{
|
||||
start = std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
void Animation::reset(double duration)
|
||||
void Animation::reset(double animation_duration)
|
||||
{
|
||||
this->duration = duration;
|
||||
duration = animation_duration;
|
||||
reset();
|
||||
}
|
||||
void Animation::reset(double duration, double start, double stop)
|
||||
void Animation::reset(double animation_duration, double animation_start, double animation_stop)
|
||||
{
|
||||
start_value = start;
|
||||
end_value = stop;
|
||||
reset(duration);
|
||||
start_value = animation_start;
|
||||
end_value = animation_stop;
|
||||
reset(animation_duration);
|
||||
}
|
||||
|
||||
static double ease_out_expo(double t)
|
||||
|
@ -22,8 +22,8 @@ public:
|
||||
|
||||
Animation(double duration = 1, double start = 0, double stop = 1);
|
||||
void reset();
|
||||
void reset(double duration);
|
||||
void reset(double duration, double start, double stop);
|
||||
void reset(double animation_duration);
|
||||
void reset(double animation_duration, double animation_start, double animation_stop);
|
||||
double value(AnimFunctions apply_function) const;
|
||||
bool done() const;
|
||||
|
||||
|
@ -297,13 +297,13 @@ D2DOverlayWindow::D2DOverlayWindow() :
|
||||
});
|
||||
}
|
||||
|
||||
void D2DOverlayWindow::show(HWND active_window, bool snappable)
|
||||
void D2DOverlayWindow::show(HWND window, bool snappable)
|
||||
{
|
||||
std::unique_lock lock(mutex);
|
||||
hidden = false;
|
||||
tasklist_buttons.clear();
|
||||
this->active_window = active_window;
|
||||
this->active_window_snappable = snappable;
|
||||
active_window = window;
|
||||
active_window_snappable = snappable;
|
||||
auto old_bck = colors.start_color_menu;
|
||||
auto colors_updated = colors.update();
|
||||
auto new_light_mode = (theme_setting == Light) || (theme_setting == System && colors.light_mode);
|
||||
@ -355,10 +355,10 @@ void D2DOverlayWindow::show(HWND active_window, bool snappable)
|
||||
total_screen.rect.top += monitor_dy;
|
||||
total_screen.rect.bottom += monitor_dy;
|
||||
tasklist.update();
|
||||
if (active_window)
|
||||
if (window)
|
||||
{
|
||||
// Ignore errors, if this fails we will just not show the thumbnail
|
||||
DwmRegisterThumbnail(hwnd, active_window, &thumbnail);
|
||||
DwmRegisterThumbnail(hwnd, window, &thumbnail);
|
||||
}
|
||||
|
||||
background_animation.reset();
|
||||
@ -644,7 +644,7 @@ void D2DOverlayWindow::hide_thumbnail()
|
||||
DwmUpdateThumbnailProperties(thumbnail, &thumb_properties);
|
||||
}
|
||||
|
||||
void D2DOverlayWindow::render(ID2D1DeviceContext5* d2d_dc)
|
||||
void D2DOverlayWindow::render(ID2D1DeviceContext5* d2d_device_context)
|
||||
{
|
||||
if (!hidden && !overlay_window_instance->overlay_visible())
|
||||
{
|
||||
@ -652,7 +652,7 @@ void D2DOverlayWindow::render(ID2D1DeviceContext5* d2d_dc)
|
||||
return;
|
||||
}
|
||||
|
||||
d2d_dc->Clear();
|
||||
d2d_device_context->Clear();
|
||||
int taskbar_icon_shortcuts_x_offset = 0, taskbar_icon_shortcuts_y_offset = 0;
|
||||
|
||||
float current_background_anim_value = (float)background_animation.value(Animation::AnimFunctions::LINEAR);
|
||||
@ -665,12 +665,12 @@ void D2DOverlayWindow::render(ID2D1DeviceContext5* d2d_dc)
|
||||
winrt::com_ptr<ID2D1SolidColorBrush> brush;
|
||||
float brush_opacity = get_overlay_opacity();
|
||||
D2D1_COLOR_F brushColor = light_mode ? D2D1::ColorF(1.0f, 1.0f, 1.0f, brush_opacity) : D2D1::ColorF(0, 0, 0, brush_opacity);
|
||||
winrt::check_hresult(d2d_dc->CreateSolidColorBrush(brushColor, brush.put()));
|
||||
winrt::check_hresult(d2d_device_context->CreateSolidColorBrush(brushColor, brush.put()));
|
||||
D2D1_RECT_F background_rect = {};
|
||||
background_rect.bottom = (float)window_height;
|
||||
background_rect.right = (float)window_width;
|
||||
d2d_dc->SetTransform(D2D1::Matrix3x2F::Identity());
|
||||
d2d_dc->FillRectangle(background_rect, brush.get());
|
||||
d2d_device_context->SetTransform(D2D1::Matrix3x2F::Identity());
|
||||
d2d_device_context->FillRectangle(background_rect, brush.get());
|
||||
|
||||
// Draw the taskbar shortcuts (the arrows with numbers)
|
||||
if (taskbar_icon_shortcuts_shown)
|
||||
@ -703,7 +703,7 @@ void D2DOverlayWindow::render(ID2D1DeviceContext5* d2d_dc)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
render_arrow(arrows[(size_t)(button.keynum) - 1], button, window_rect, use_overlay->get_scale(), d2d_dc, taskbar_icon_shortcuts_x_offset, taskbar_icon_shortcuts_y_offset);
|
||||
render_arrow(arrows[(size_t)(button.keynum) - 1], button, window_rect, use_overlay->get_scale(), d2d_device_context, taskbar_icon_shortcuts_x_offset, taskbar_icon_shortcuts_y_offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -793,7 +793,7 @@ void D2DOverlayWindow::render(ID2D1DeviceContext5* d2d_dc)
|
||||
{
|
||||
brushColor = D2D1::ColorF(colors.start_color_menu, miniature_shown ? current_global_windows_shortcuts_anim_value * 0.9f : current_global_windows_shortcuts_anim_value * 0.3f);
|
||||
brush = nullptr;
|
||||
winrt::check_hresult(d2d_dc->CreateSolidColorBrush(brushColor, brush.put()));
|
||||
winrt::check_hresult(d2d_device_context->CreateSolidColorBrush(brushColor, brush.put()));
|
||||
for (auto& monitor : monitors)
|
||||
{
|
||||
D2D1_RECT_F monitor_rect;
|
||||
@ -802,22 +802,22 @@ void D2DOverlayWindow::render(ID2D1DeviceContext5* d2d_dc)
|
||||
monitor_rect.top = (float)((monitor_size.top() + monitor_dy) * rect_and_scale.scale + rect_and_scale.rect.top);
|
||||
monitor_rect.right = (float)((monitor_size.right() + monitor_dx) * rect_and_scale.scale + rect_and_scale.rect.left);
|
||||
monitor_rect.bottom = (float)((monitor_size.bottom() + monitor_dy) * rect_and_scale.scale + rect_and_scale.rect.top);
|
||||
d2d_dc->SetTransform(D2D1::Matrix3x2F::Identity());
|
||||
d2d_dc->FillRectangle(monitor_rect, brush.get());
|
||||
d2d_device_context->SetTransform(D2D1::Matrix3x2F::Identity());
|
||||
d2d_device_context->FillRectangle(monitor_rect, brush.get());
|
||||
}
|
||||
}
|
||||
// Finalize the overlay - dimm the buttons if no thumbnail is present and show "No active window"
|
||||
use_overlay->toggle_window_group(miniature_shown || window_state == MINIMIZED);
|
||||
if (!miniature_shown && window_state != MINIMIZED)
|
||||
{
|
||||
no_active.render(d2d_dc);
|
||||
no_active.render(d2d_device_context);
|
||||
window_state = UNKNOWN;
|
||||
}
|
||||
|
||||
// Set the animation - move the draw window according to animation step
|
||||
int global_windows_shortcuts_y_offset = (int)(pos_global_windows_shortcuts_anim_value * use_overlay->height() * use_overlay->get_scale());
|
||||
auto popIn = D2D1::Matrix3x2F::Translation(0, (float)global_windows_shortcuts_y_offset);
|
||||
d2d_dc->SetTransform(popIn);
|
||||
d2d_device_context->SetTransform(popIn);
|
||||
|
||||
// Animate keys
|
||||
for (unsigned id = 0; id < key_animations.size();)
|
||||
@ -846,7 +846,7 @@ void D2DOverlayWindow::render(ID2D1DeviceContext5* d2d_dc)
|
||||
++id;
|
||||
}
|
||||
// Finally: render the overlay...
|
||||
use_overlay->render(d2d_dc);
|
||||
use_overlay->render(d2d_device_context);
|
||||
// ... window arrows texts ...
|
||||
std::wstring left, right, up, down;
|
||||
bool left_disabled = false;
|
||||
@ -925,13 +925,13 @@ void D2DOverlayWindow::render(ID2D1DeviceContext5* d2d_dc)
|
||||
}
|
||||
auto text_color = D2D1::ColorF(light_mode ? 0x222222 : 0xDDDDDD, active_window_snappable && (miniature_shown || window_state == MINIMIZED) ? 1.0f : 0.3f);
|
||||
use_overlay->find_element(L"KeyUpGroup")->SetAttributeValue(L"fill-opacity", up_disabled ? 0.3f : 1.0f);
|
||||
text.set_alignment_center().write(d2d_dc, text_color, use_overlay->get_maximize_label(), up);
|
||||
text.set_alignment_center().write(d2d_device_context, text_color, use_overlay->get_maximize_label(), up);
|
||||
use_overlay->find_element(L"KeyDownGroup")->SetAttributeValue(L"fill-opacity", down_disabled ? 0.3f : 1.0f);
|
||||
text.write(d2d_dc, text_color, use_overlay->get_minimize_label(), down);
|
||||
text.write(d2d_device_context, text_color, use_overlay->get_minimize_label(), down);
|
||||
use_overlay->find_element(L"KeyLeftGroup")->SetAttributeValue(L"fill-opacity", left_disabled ? 0.3f : 1.0f);
|
||||
text.set_alignment_right().write(d2d_dc, text_color, use_overlay->get_snap_left(), left);
|
||||
text.set_alignment_right().write(d2d_device_context, text_color, use_overlay->get_snap_left(), left);
|
||||
use_overlay->find_element(L"KeyRightGroup")->SetAttributeValue(L"fill-opacity", right_disabled ? 0.3f : 1.0f);
|
||||
text.set_alignment_left().write(d2d_dc, text_color, use_overlay->get_snap_right(), right);
|
||||
text.set_alignment_left().write(d2d_device_context, text_color, use_overlay->get_snap_right(), right);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ class D2DOverlayWindow : public D2DWindow
|
||||
{
|
||||
public:
|
||||
D2DOverlayWindow();
|
||||
void show(HWND active_window, bool snappable);
|
||||
void show(HWND window, bool snappable);
|
||||
~D2DOverlayWindow();
|
||||
void apply_overlay_opacity(float opacity);
|
||||
void apply_press_time_for_global_windows_shortcuts(int press_time);
|
||||
@ -57,9 +57,9 @@ public:
|
||||
void quick_hide();
|
||||
|
||||
HWND get_window_handle();
|
||||
void SetWindowCloseType(std::wstring windowCloseType)
|
||||
void SetWindowCloseType(std::wstring wCloseType)
|
||||
{
|
||||
this->windowCloseType = windowCloseType;
|
||||
windowCloseType = wCloseType;
|
||||
}
|
||||
|
||||
private:
|
||||
@ -68,7 +68,7 @@ private:
|
||||
void hide_thumbnail();
|
||||
virtual void init() override;
|
||||
virtual void resize() override;
|
||||
virtual void render(ID2D1DeviceContext5* d2d_dc) override;
|
||||
virtual void render(ID2D1DeviceContext5* d2dd2d_device_context_dc) override;
|
||||
virtual void on_show() override;
|
||||
virtual void on_hide() override;
|
||||
float get_overlay_opacity();
|
||||
|
@ -56,14 +56,14 @@ namespace NonLocalizable
|
||||
struct FancyZones : public winrt::implements<FancyZones, IFancyZones, IFancyZonesCallback>, public SettingsObserver
|
||||
{
|
||||
public:
|
||||
FancyZones(HINSTANCE hinstance, std::function<void()> disableModuleCallback) noexcept :
|
||||
FancyZones(HINSTANCE hinstance, std::function<void()> disableModuleCallbackFunction) noexcept :
|
||||
SettingsObserver({ SettingId::EditorHotkey, SettingId::PrevTabHotkey, SettingId::NextTabHotkey, SettingId::SpanZonesAcrossMonitors }),
|
||||
m_hinstance(hinstance),
|
||||
m_windowMoveHandler([this]() {
|
||||
PostMessageW(m_window, WM_PRIV_LOCATIONCHANGE, NULL, NULL);
|
||||
})
|
||||
{
|
||||
this->disableModuleCallback = std::move(disableModuleCallback);
|
||||
this->disableModuleCallback = std::move(disableModuleCallbackFunction);
|
||||
|
||||
FancyZonesSettings::instance().LoadSettings();
|
||||
|
||||
|
@ -1,6 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
// disabling warning 4458 - declaration of 'identifier' hides class member
|
||||
// to avoid warnings from GDI files - can't add winRT directory to external code
|
||||
// in the Cpp.Build.props
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4458)
|
||||
#include "gdiplus.h"
|
||||
#pragma warning(pop)
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
@ -2,7 +2,13 @@
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
// disabling warning 4458 - declaration of 'identifier' hides class member
|
||||
// to avoid warnings from GDI files - can't add winRT directory to external code
|
||||
// in the Cpp.Build.props
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4458)
|
||||
#include "gdiplus.h"
|
||||
#pragma warning(pop)
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
@ -21,7 +21,13 @@
|
||||
#include <mutex>
|
||||
#include <fileapi.h>
|
||||
|
||||
// disabling warning 4458 - declaration of 'identifier' hides class member
|
||||
// to avoid warnings from GDI files - can't add winRT directory to external code
|
||||
// in the Cpp.Build.props
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4458)
|
||||
#include <gdiplus.h>
|
||||
#pragma warning(pop)
|
||||
|
||||
// Non-Localizable strings
|
||||
namespace NonLocalizable
|
||||
@ -58,7 +64,6 @@ namespace
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
HWND NewZonesOverlayWindow(Rect position, HINSTANCE hinstance, WorkArea* owner)
|
||||
{
|
||||
HWND windowFromPool = ExtractWindow();
|
||||
@ -666,4 +671,3 @@ LRESULT CALLBACK WorkArea::s_WndProc(HWND window, UINT message, WPARAM wparam, L
|
||||
return (thisRef != nullptr) ? thisRef->WndProc(message, wparam, lparam) :
|
||||
DefWindowProc(window, message, wparam, lparam);
|
||||
}
|
||||
|
||||
|
@ -239,8 +239,8 @@ namespace FancyZonesUnitTests
|
||||
|
||||
TEST_METHOD (FromJsonInvalidTypes)
|
||||
{
|
||||
json::JsonObject m_json = json::JsonObject::Parse(L"{\"ref-width\": true, \"ref-height\": \"string\", \"zones\": [{\"X\": \"11\", \"Y\": \"22\", \"width\": \".\", \"height\": \"*\"}, {\"X\": null, \"Y\": {}, \"width\": [], \"height\": \"абвгд\"}]}");
|
||||
Assert::IsFalse(CanvasLayoutInfoJSON::FromJson(m_json).has_value());
|
||||
json::JsonObject local_json = json::JsonObject::Parse(L"{\"ref-width\": true, \"ref-height\": \"string\", \"zones\": [{\"X\": \"11\", \"Y\": \"22\", \"width\": \".\", \"height\": \"*\"}, {\"X\": null, \"Y\": {}, \"width\": [], \"height\": \"абвгд\"}]}");
|
||||
Assert::IsFalse(CanvasLayoutInfoJSON::FromJson(local_json).has_value());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -46,7 +46,14 @@
|
||||
#include <common/utils/window.h>
|
||||
#include <common/version/version.h>
|
||||
#include <common/utils/string_utils.h>
|
||||
|
||||
// disabling warning 4458 - declaration of 'identifier' hides class member
|
||||
// to avoid warnings from GDI files - can't add winRT directory to external code
|
||||
// in the Cpp.Build.props
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4458)
|
||||
#include <gdiplus.h>
|
||||
#pragma warning(pop)
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -95,7 +95,7 @@ namespace
|
||||
}
|
||||
|
||||
// Enumerate all the events in the result set.
|
||||
void PrintResults(EVT_HANDLE hResults)
|
||||
void PrintResults(EVT_HANDLE results)
|
||||
{
|
||||
DWORD status = ERROR_SUCCESS;
|
||||
EVT_HANDLE hEvents[BATCH_SIZE];
|
||||
@ -104,7 +104,7 @@ namespace
|
||||
while (true)
|
||||
{
|
||||
// Get a block of events from the result set.
|
||||
if (!EvtNext(hResults, BATCH_SIZE, hEvents, INFINITE, 0, &dwReturned))
|
||||
if (!EvtNext(results, BATCH_SIZE, hEvents, INFINITE, 0, &dwReturned))
|
||||
{
|
||||
if (ERROR_NO_MORE_ITEMS != (status = GetLastError()))
|
||||
{
|
||||
|
@ -162,8 +162,8 @@ private:
|
||||
{
|
||||
auto path = tmpDir;
|
||||
path += "installationFolderStructure.txt";
|
||||
std::wofstream os = std::wofstream(path);
|
||||
return os;
|
||||
std::wofstream out_s = std::wofstream(path);
|
||||
return out_s;
|
||||
}
|
||||
public:
|
||||
Reporter(const path& tmpDir)
|
||||
|
Loading…
Reference in New Issue
Block a user