-
Notifications
You must be signed in to change notification settings - Fork 136
Open
Description
in function refresh_locale_list
if user delete first keyboardlayout, locale_previous will nullptr.
right code is the next :
// Go though the linked list and remove KeyboardLocale's that are
// no longer loaded.
while (locale_item != NULL) {
// Check to see if the old HKL is in the new list.
bool is_loaded = false;
for (int i = 0; i < new_size && !is_loaded; i++) {
if (locale_item->id == hkl_list[i]) {
// Flag and jump out of the loop.
hkl_list[i] = NULL;
is_loaded = true;
}
}
if (is_loaded) {
logger(LOG_LEVEL_DEBUG, "%s [%u]: Found locale ID %#p in the cache.\n",
__FUNCTION__, __LINE__, locale_item->id);
// Set the previous local to the current locale.
locale_previous = locale_item;
// Check and see if the locale is our current active locale.
if (locale_item->id == hlk_focus) {
locale_current = locale_item;
}
count++;
// Iterate to the next linked list item.
locale_item = locale_item->next;
} else {
logger(LOG_LEVEL_DEBUG, "%s [%u]: Removing locale ID %#p from the cache.\n",
__FUNCTION__, __LINE__, locale_item->id);
// Make sure the locale_current points NULL or something valid.
if (locale_item == locale_current) {
locale_current = NULL;
}
//FIXME.
// this line code equal locale_previous == NULL
if (locale_item == locale_first)
{
KeyboardLocale* locale_temp = locale_item->next;
// Free the memory used by locale_item;
free(locale_item);
locale_first = locale_temp;
locale_item = locale_temp;
}
else
{
// If the old id is not in the new list, remove it.
locale_previous->next = locale_item->next;
// Free the memory used by locale_item;
free(locale_item);
// Iterate to the next linked list item.
locale_item = locale_previous->next;
}
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels