mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 01:20:42 -05:00
kms/connector: Fix updating the state when drmConnector is NULL
When a docking station is disconnected, a few previously existing DRM connectors may now be gone. When this happens, getting them via the libdrm API results in NULL pointers returning, and we need to handle this gracefully by making sure the connector state is properly updated. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2097>
This commit is contained in:
parent
989cc2e247
commit
8546ca31ff
@ -138,7 +138,9 @@ sync_fd_held (MetaKmsConnector *connector,
|
|||||||
{
|
{
|
||||||
gboolean should_hold_fd;
|
gboolean should_hold_fd;
|
||||||
|
|
||||||
should_hold_fd = connector->current_state->current_crtc_id != 0;
|
should_hold_fd =
|
||||||
|
connector->current_state &&
|
||||||
|
connector->current_state->current_crtc_id != 0;
|
||||||
|
|
||||||
if (connector->fd_held == should_hold_fd)
|
if (connector->fd_held == should_hold_fd)
|
||||||
return;
|
return;
|
||||||
@ -569,6 +571,13 @@ meta_kms_connector_read_state (MetaKmsConnector *connector,
|
|||||||
current_state = g_steal_pointer (&connector->current_state);
|
current_state = g_steal_pointer (&connector->current_state);
|
||||||
changes = META_KMS_UPDATE_CHANGE_NONE;
|
changes = META_KMS_UPDATE_CHANGE_NONE;
|
||||||
|
|
||||||
|
if (!drm_connector)
|
||||||
|
{
|
||||||
|
if (current_state)
|
||||||
|
changes = META_KMS_UPDATE_CHANGE_FULL;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
if (drm_connector->connection != DRM_MODE_CONNECTED)
|
if (drm_connector->connection != DRM_MODE_CONNECTED)
|
||||||
{
|
{
|
||||||
if (drm_connector->connection != connector->connection)
|
if (drm_connector->connection != connector->connection)
|
||||||
@ -577,7 +586,7 @@ meta_kms_connector_read_state (MetaKmsConnector *connector,
|
|||||||
changes |= META_KMS_UPDATE_CHANGE_FULL;
|
changes |= META_KMS_UPDATE_CHANGE_FULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return changes;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
state = meta_kms_connector_state_new ();
|
state = meta_kms_connector_state_new ();
|
||||||
@ -616,7 +625,7 @@ meta_kms_connector_read_state (MetaKmsConnector *connector,
|
|||||||
changes |= connector_changes;
|
changes |= connector_changes;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changes != META_KMS_UPDATE_CHANGE_NONE)
|
out:
|
||||||
sync_fd_held (connector, impl_device);
|
sync_fd_held (connector, impl_device);
|
||||||
|
|
||||||
return changes;
|
return changes;
|
||||||
@ -634,13 +643,10 @@ meta_kms_connector_update_state (MetaKmsConnector *connector,
|
|||||||
drm_connector = drmModeGetConnector (meta_kms_impl_device_get_fd (impl_device),
|
drm_connector = drmModeGetConnector (meta_kms_impl_device_get_fd (impl_device),
|
||||||
connector->id);
|
connector->id);
|
||||||
|
|
||||||
if (!drm_connector)
|
|
||||||
return META_KMS_UPDATE_CHANGE_FULL;
|
|
||||||
|
|
||||||
changes = meta_kms_connector_read_state (connector, impl_device,
|
changes = meta_kms_connector_read_state (connector, impl_device,
|
||||||
drm_connector,
|
drm_connector,
|
||||||
drm_resources);
|
drm_resources);
|
||||||
drmModeFreeConnector (drm_connector);
|
g_clear_pointer (&drm_connector, drmModeFreeConnector);
|
||||||
|
|
||||||
return changes;
|
return changes;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user