app: clean the controller manager off invalid controllers after…
… controllerrc config file deserialization. This is the first part to handle #13787 and not a bad idea by itself per-se, since we remove one way to crash GIMP by creating an invalid controllerrc file.
This commit is contained in:
parent
5831b7ddcb
commit
57f8e233f7
1 changed files with 23 additions and 2 deletions
|
|
@ -71,6 +71,9 @@ static gboolean gimp_controller_manager_event_mapped (GimpControllerInfo
|
|||
const gchar *action_name,
|
||||
GimpControllerManager *manager);
|
||||
|
||||
static gboolean gimp_controller_search_invalid (GimpObject *object,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpControllerManager, gimp_controller_manager,
|
||||
GIMP_TYPE_LIST)
|
||||
|
|
@ -164,8 +167,9 @@ void
|
|||
gimp_controller_manager_restore (GimpControllerManager *self,
|
||||
GimpUIManager *ui_manager)
|
||||
{
|
||||
GFile *file;
|
||||
GError *error = NULL;
|
||||
GFile *file;
|
||||
GimpObject *found;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_if_fail (GIMP_IS_CONTROLLER_MANAGER (self));
|
||||
g_return_if_fail (GIMP_IS_UI_MANAGER (ui_manager));
|
||||
|
|
@ -217,6 +221,16 @@ gimp_controller_manager_restore (GimpControllerManager *self,
|
|||
|
||||
gimp_list_reverse (GIMP_LIST (self));
|
||||
|
||||
while ((found = gimp_container_search (GIMP_CONTAINER (self),
|
||||
(GimpContainerSearchFunc) gimp_controller_search_invalid,
|
||||
NULL)))
|
||||
/* Clean out the manager off invalid controllers. This may happen
|
||||
* in particular with the removed GimpControllerMouse, which our
|
||||
* migration code would translate as a deserialized
|
||||
* GimpControllerInfo with NULL controller.
|
||||
*/
|
||||
gimp_container_remove (GIMP_CONTAINER (self), found);
|
||||
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
|
|
@ -362,3 +376,10 @@ gimp_controller_manager_event_mapped (GimpControllerInfo *info,
|
|||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_controller_search_invalid (GimpObject *object,
|
||||
gpointer user_data)
|
||||
{
|
||||
return (GIMP_CONTROLLER_INFO (object)->controller == NULL);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue