color-device: Don't attempt to set GAMMA_LUT if LUT size is zero
This might happen on e.g. virtual machines. If we don't skip trying,
we'll end up crashing because we'll fail to create a look up table since
the size must be greater than zero to make any sense.
Fixes: baef39e603
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2415
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2611>
This commit is contained in:
parent
1bd06e645e
commit
255cd9a9ff
2 changed files with 10 additions and 6 deletions
|
@ -1171,7 +1171,6 @@ meta_color_device_update (MetaColorDevice *color_device,
|
||||||
MetaColorProfile *color_profile;
|
MetaColorProfile *color_profile;
|
||||||
MetaMonitor *monitor;
|
MetaMonitor *monitor;
|
||||||
size_t lut_size;
|
size_t lut_size;
|
||||||
g_autoptr (MetaGammaLut) lut = NULL;
|
|
||||||
|
|
||||||
color_profile = meta_color_device_get_assigned_profile (color_device);
|
color_profile = meta_color_device_get_assigned_profile (color_device);
|
||||||
if (!color_profile)
|
if (!color_profile)
|
||||||
|
@ -1206,11 +1205,16 @@ meta_color_device_update (MetaColorDevice *color_device,
|
||||||
}
|
}
|
||||||
|
|
||||||
lut_size = meta_monitor_get_gamma_lut_size (monitor);
|
lut_size = meta_monitor_get_gamma_lut_size (monitor);
|
||||||
lut = meta_color_profile_generate_gamma_lut (color_profile,
|
if (lut_size > 0)
|
||||||
temperature,
|
{
|
||||||
lut_size);
|
g_autoptr (MetaGammaLut) lut = NULL;
|
||||||
|
|
||||||
meta_monitor_set_gamma_lut (monitor, lut);
|
lut = meta_color_profile_generate_gamma_lut (color_profile,
|
||||||
|
temperature,
|
||||||
|
lut_size);
|
||||||
|
|
||||||
|
meta_monitor_set_gamma_lut (monitor, lut);
|
||||||
|
}
|
||||||
|
|
||||||
g_signal_emit (color_device, signals[UPDATED], 0);
|
g_signal_emit (color_device, signals[UPDATED], 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -488,7 +488,7 @@ meta_color_profile_generate_gamma_lut (MetaColorProfile *color_profile,
|
||||||
unsigned int temperature,
|
unsigned int temperature,
|
||||||
size_t lut_size)
|
size_t lut_size)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (lut_size > 0, NULL);
|
g_assert (lut_size > 0);
|
||||||
|
|
||||||
if (color_profile->calibration->has_vcgt)
|
if (color_profile->calibration->has_vcgt)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue