Skip to content

Commit

Permalink
[runner] rename 'module' variables (#8999)
Browse files Browse the repository at this point in the history
rename all occurrences of 'module' to 'pt_module' to prevent intellisense error
  • Loading branch information
enricogior committed Jan 8, 2021
1 parent cccd2c0 commit dbda4d5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/runner/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ int runner(bool isProcessElevated)
{
try
{
auto module = load_powertoy(moduleSubdir);
modules().emplace(module->get_key(), std::move(module));
auto pt_module = load_powertoy(moduleSubdir);
modules().emplace(pt_module->get_key(), std::move(pt_module));
}
catch (...)
{
Expand Down
26 changes: 13 additions & 13 deletions src/runner/powertoy_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,29 @@ PowertoyModule load_powertoy(const std::wstring_view filename)
FreeLibrary(handle);
winrt::throw_last_error();
}
auto module = create();
if (!module)
auto pt_module = create();
if (!pt_module)
{
FreeLibrary(handle);
winrt::throw_hresult(winrt::hresult(E_POINTER));
}
return PowertoyModule(module, handle);
return PowertoyModule(pt_module, handle);
}

json::JsonObject PowertoyModule::json_config() const
{
int size = 0;
module->get_config(nullptr, &size);
pt_module->get_config(nullptr, &size);
std::wstring result;
result.resize(size - 1);
module->get_config(result.data(), &size);
pt_module->get_config(result.data(), &size);
return json::JsonObject::Parse(result);
}

PowertoyModule::PowertoyModule(PowertoyModuleIface* module, HMODULE handle) :
handle(handle), module(module)
PowertoyModule::PowertoyModule(PowertoyModuleIface* pt_module, HMODULE handle) :
handle(handle), pt_module(pt_module)
{
if (!module)
if (!pt_module)
{
throw std::runtime_error("Module not initialized");
}
Expand All @@ -49,17 +49,17 @@ PowertoyModule::PowertoyModule(PowertoyModuleIface* module, HMODULE handle) :

void PowertoyModule::update_hotkeys()
{
CentralizedKeyboardHook::ClearModuleHotkeys(module->get_key());
CentralizedKeyboardHook::ClearModuleHotkeys(pt_module->get_key());

size_t hotkeyCount = module->get_hotkeys(nullptr, 0);
size_t hotkeyCount = pt_module->get_hotkeys(nullptr, 0);
std::vector<PowertoyModuleIface::Hotkey> hotkeys(hotkeyCount);
module->get_hotkeys(hotkeys.data(), hotkeyCount);
pt_module->get_hotkeys(hotkeys.data(), hotkeyCount);

auto modulePtr = module.get();
auto modulePtr = pt_module.get();

for (size_t i = 0; i < hotkeyCount; i++)
{
CentralizedKeyboardHook::SetHotkeyAction(module->get_key(), hotkeys[i], [modulePtr, i] {
CentralizedKeyboardHook::SetHotkeyAction(pt_module->get_key(), hotkeys[i], [modulePtr, i] {
return modulePtr->on_hotkey(i);
});
}
Expand Down
12 changes: 6 additions & 6 deletions src/runner/powertoy_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

struct PowertoyModuleDeleter
{
void operator()(PowertoyModuleIface* module) const
void operator()(PowertoyModuleIface* pt_module) const
{
if (module)
if (pt_module)
{
module->destroy();
pt_module->destroy();
}
}
};
Expand All @@ -31,11 +31,11 @@ struct PowertoyModuleDLLDeleter
class PowertoyModule
{
public:
PowertoyModule(PowertoyModuleIface* module, HMODULE handle);
PowertoyModule(PowertoyModuleIface* pt_module, HMODULE handle);

inline PowertoyModuleIface* operator->()
{
return module.get();
return pt_module.get();
}

json::JsonObject json_config() const;
Expand All @@ -44,7 +44,7 @@ class PowertoyModule

private:
std::unique_ptr<HMODULE, PowertoyModuleDLLDeleter> handle;
std::unique_ptr<PowertoyModuleIface, PowertoyModuleDeleter> module;
std::unique_ptr<PowertoyModuleIface, PowertoyModuleDeleter> pt_module;
};

PowertoyModule load_powertoy(const std::wstring_view filename);
Expand Down

0 comments on commit dbda4d5

Please sign in to comment.