libgimpwidgets: Fix CRITICAL when no monitor profile is set

Resolves #11246

On Windows, a CRITICAL was being repeatedly thrown if you
didn't have a monitor profile set. This is because we were trying to
pass a NULL value to g_utf16_to_utf8 () whenever we needed to
convert a GeglColor.
This patch fixes it by checking if the monitor profile filename is NULL
before trying to convert it.
This commit is contained in:
Alx Sa 2024-04-07 12:52:24 +00:00
parent 841d926f4b
commit 0ec02a4fa9
1 changed files with 17 additions and 14 deletions

View File

@ -714,25 +714,28 @@ gimp_monitor_get_color_profile (GdkMonitor *monitor)
}
}
filename = g_utf16_to_utf8 (filename_utf16, -1, NULL, NULL, NULL);
if (filename_utf16 != NULL)
{
filename = g_utf16_to_utf8 (filename_utf16, -1, NULL, NULL, NULL);
GetColorDirectoryW (NULL, NULL, &len);
dir_utf16 = g_malloc0 (len);
GetColorDirectoryW (NULL, dir_utf16, &len);
GetColorDirectoryW (NULL, NULL, &len);
dir_utf16 = g_malloc0 (len);
GetColorDirectoryW (NULL, dir_utf16, &len);
dir = g_utf16_to_utf8 (dir_utf16, -1, NULL, NULL, NULL);
dir = g_utf16_to_utf8 (dir_utf16, -1, NULL, NULL, NULL);
fullpath = g_build_filename (dir, filename, NULL);
file = g_file_new_for_path (fullpath);
fullpath = g_build_filename (dir, filename, NULL);
file = g_file_new_for_path (fullpath);
profile = gimp_color_profile_new_from_file (file, NULL);
g_object_unref (file);
profile = gimp_color_profile_new_from_file (file, NULL);
g_object_unref (file);
g_free (fullpath);
g_free (dir);
g_free (dir_utf16);
g_free (filename);
g_free (filename_utf16);
g_free (fullpath);
g_free (dir);
g_free (dir_utf16);
g_free (filename);
g_free (filename_utf16);
}
}
}
}