1
0
mirror of https://gitlab.gnome.org/GNOME/evince synced 2024-06-30 22:54:23 +00:00

use default color when annotation has no color

Annotations may come with a NULL color, use
a default color there instead of letting
undefined GdkRGBA to crash the application.

We take the chance to share this default color
to be the same we already use when creating
an annotation from Evince.

We also take the chance to replace deprecated
function ev_annotation_set_color() with
ev_annotation_set_rgba()

Fixes crash in #1800
This commit is contained in:
Nelson Benítez León 2022-06-05 11:52:56 -04:00
parent 32e832611b
commit c76be8ba6f
3 changed files with 7 additions and 3 deletions

View File

@ -2701,7 +2701,9 @@ poppler_annot_color_to_gdk_rgba (PopplerAnnot *poppler_annot,
color->alpha = 1.0;
g_free (poppler_color);
} /* TODO: else use a default color */
} else { /* default color */
*color = EV_ANNOTATION_DEFAULT_COLOR;
}
}
static EvAnnotationTextIcon

View File

@ -115,6 +115,8 @@ typedef enum {
EV_ANNOTATION_TEXT_MARKUP_SQUIGGLY
} EvAnnotationTextMarkupType;
#define EV_ANNOTATION_DEFAULT_COLOR ((const GdkRGBA) { 1., 1., 0, 1.});
/* EvAnnotation */
EV_PUBLIC
GType ev_annotation_get_type (void) G_GNUC_CONST;

View File

@ -3717,7 +3717,7 @@ ev_view_create_annotation_real (EvView *view,
EvAnnotation *annot;
EvRectangle doc_rect, popup_rect;
EvPage *page;
GdkColor color = { 0, 65535, 65535, 0 };
GdkRGBA color = EV_ANNOTATION_DEFAULT_COLOR;
GdkRectangle view_rect;
cairo_region_t *region;
@ -3749,7 +3749,7 @@ ev_view_create_annotation_real (EvView *view,
g_object_unref (page);
ev_annotation_set_area (annot, &doc_rect);
ev_annotation_set_color (annot, &color);
ev_annotation_set_rgba (annot, &color);
if (EV_IS_ANNOTATION_MARKUP (annot)) {
popup_rect.x1 = doc_rect.x2;