coolermaster keyboard rescan crash

This commit is contained in:
Tam D 2024-06-27 13:09:52 +00:00 committed by Adam Honse
parent d1a638e6f0
commit 5df9dcdf9c
4 changed files with 19 additions and 12 deletions

View file

@ -48,10 +48,7 @@ CMKeyboardAbstractController::CMKeyboardAbstractController(hid_device* dev_handl
CMKeyboardAbstractController::~CMKeyboardAbstractController()
{
if(m_pDev)
{
hid_close(m_pDev);
}
hid_close(m_pDev);
};
std::string CMKeyboardAbstractController::GetDeviceName()

View file

@ -57,7 +57,7 @@ class CMKeyboardAbstractController
{
public:
CMKeyboardAbstractController(hid_device* dev_handle, hid_device_info* dev_info);
~CMKeyboardAbstractController();
virtual ~CMKeyboardAbstractController();
/*---------------------------------------------------------*\
| Common USB controller fuctions |

View file

@ -49,13 +49,26 @@ RGBController_CMKeyboardController::RGBController_CMKeyboardController(CMKeyboar
RGBController_CMKeyboardController::~RGBController_CMKeyboardController()
{
for(size_t i = 0; i < m_pUnknownKeyNames.size(); i++)
/*---------------------------------------------------------*\
| Delete the matrix map |
\*---------------------------------------------------------*/
for(unsigned int zone_index = 0; zone_index < zones.size(); zone_index++)
{
if(m_pUnknownKeyNames[i])
if(zones[zone_index].matrix_map != NULL)
{
delete(m_pUnknownKeyNames[i]);
if(zones[zone_index].matrix_map->map != NULL)
{
delete zones[zone_index].matrix_map->map;
}
delete zones[zone_index].matrix_map;
}
}
if(m_pController)
{
delete m_pController;
}
}
#define COOLERMASTER_ZONES_MAX 1
@ -88,8 +101,6 @@ void RGBController_CMKeyboardController::SetupZones()
matrix_map_type * new_map = new matrix_map_type;
new_zone.matrix_map = new_map;
new_map->map = new unsigned int[new_map->height * new_map->width];
if(coolermaster->layout_new->base_size != KEYBOARD_SIZE_EMPTY)
{
/*---------------------------------------------------------*\
@ -100,6 +111,7 @@ void RGBController_CMKeyboardController::SetupZones()
new_map->height = new_kb.GetRowCount();
new_map->width = new_kb.GetColumnCount();
new_map->map = new unsigned int[new_map->height * new_map->width];
/*---------------------------------------------------------*\
| Matrix map still uses declared zone rows and columns |

View file

@ -38,7 +38,5 @@ private:
CMKeyboardAbstractController* m_pController;;
KeyboardLayoutManager* m_pLayoutManager;
KEYBOARD_LAYOUT m_keyboardLayout;
KEYBOARD_SIZE m_keyboardSize;
layout_values m_layoutValues;
std::vector<char *> m_pUnknownKeyNames;
};