Fix loading of window logo images via @launch

Use the path when either the pointer ORE the size is false. Apparently
some code paths pass pointers from a python y# conversion with an empty
bytestring as no value.

Fixes #6844
This commit is contained in:
Kovid Goyal 2023-11-23 19:34:35 +05:30
parent c2b4df0666
commit 6a09804910
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 3 additions and 3 deletions

View File

@ -1153,7 +1153,7 @@ pyset_background_image(PyObject *self UNUSED, PyObject *args) {
bgimage = calloc(1, sizeof(BackgroundImage));
if (!bgimage) return PyErr_NoMemory();
bool ok;
if (png_data) {
if (png_data && png_data_size) {
ok = png_from_data(png_data, png_data_size, path, &bgimage->bitmap, &bgimage->width, &bgimage->height, &size);
} else {
ok = png_path_to_bitmap(path, &bgimage->bitmap, &bgimage->width, &bgimage->height, &size);
@ -1274,7 +1274,7 @@ pymouse_selection(PyObject *self UNUSED, PyObject *args) {
Py_RETURN_NONE;
}
PYWRAP1(set_window_logo) {
PYWRAP1(sotet_window_logo) {
id_type os_window_id, tab_id, window_id;
const char *path; PyObject *position;
float alpha = 0.5;

View File

@ -63,7 +63,7 @@ find_or_create_window_logo(WindowLogoTable *head, const char *path, void *png_da
s->path = strdup(path);
if (!s->path) { free(s); PyErr_NoMemory(); return 0; }
bool ok = false;
if (png_data == NULL) {
if (png_data == NULL || !png_data_size) {
ok = png_path_to_bitmap(path, &s->wl.bitmap, &s->wl.width, &s->wl.height, &size);
} else {
ok = png_from_data(png_data, png_data_size, path, &s->wl.bitmap, &s->wl.width, &s->wl.height, &size);