Skip to content
This repository has been archived by the owner on Nov 17, 2020. It is now read-only.

Commit

Permalink
win32: plug leak when drawing handles
Browse files Browse the repository at this point in the history
The cairo context was always created but only ever used
and destroyed(!) in the second if block (!GTK_IS_PANED (widget))
so moving around the gdk_cairo_create call would have
been the obvious fix.

However, said if block is not used at all, so clean
up draw_handle instead.

https://bugzilla.gnome.org/show_bug.cgi?id=663543
  • Loading branch information
dieterv committed Nov 9, 2011
1 parent 2ae574a commit d8c2db3
Showing 1 changed file with 17 additions and 80 deletions.
97 changes: 17 additions & 80 deletions modules/engines/ms-windows/msw_style.c
Expand Up @@ -3253,25 +3253,24 @@ draw_resize_grip (GtkStyle *style,
}

static void
draw_handle (GtkStyle *style,
GdkWindow *window,
GtkStateType state_type,
GtkShadowType shadow_type,
GdkRectangle *area,
GtkWidget *widget,
const gchar *detail,
gint x,
gint y, gint width, gint height, GtkOrientation orientation)
draw_handle (GtkStyle *style,
GdkWindow *window,
GtkStateType state_type,
GtkShadowType shadow_type,
GdkRectangle *area,
GtkWidget *widget,
const gchar *detail,
gint x,
gint y,
gint width,
gint height,
GtkOrientation orientation)
{
HDC dc;
RECT rect;
XpDCInfo dc_info;
cairo_t *cr;

cr = gdk_cairo_create (window);

if (is_toolbar_child (widget))
{
HDC dc;
RECT rect;
XpDCInfo dc_info;
XpThemeElement hndl;

sanitize_size (window, &width, &height);
Expand All @@ -3282,25 +3281,18 @@ draw_handle (GtkStyle *style,
pos = gtk_handle_box_get_handle_position (GTK_HANDLE_BOX (widget));

if (pos == GTK_POS_TOP || pos == GTK_POS_BOTTOM)
{
orientation = GTK_ORIENTATION_HORIZONTAL;
}
else
{
orientation = GTK_ORIENTATION_VERTICAL;
}
}

if (orientation == GTK_ORIENTATION_VERTICAL)
hndl = XP_THEME_ELEMENT_REBAR_GRIPPER_V;
else
hndl = XP_THEME_ELEMENT_REBAR_GRIPPER_H;

if (xp_theme_draw (window, hndl, style, x, y, width, height,
state_type, area))
{
return;
}
if (xp_theme_draw (window, hndl, style, x, y, width, height, state_type, area))
return;

dc = get_window_dc (style, window, state_type, &dc_info, x, y, width, height, &rect);

Expand All @@ -3323,61 +3315,6 @@ draw_handle (GtkStyle *style,
release_window_dc (&dc_info);
return;
}

if (!GTK_IS_PANED (widget))
{
gint xthick, ythick;
GdkColor *light, *dark, *shadow;
GdkRectangle dest;

sanitize_size (window, &width, &height);

gtk_paint_box (style, window, state_type, shadow_type, area,
widget, detail, x, y, width, height);

light = &style->light[state_type];
dark = &style->dark[state_type];
shadow = &style->mid[state_type];

xthick = style->xthickness;
ythick = style->ythickness;

dest.x = x + xthick;
dest.y = y + ythick;
dest.width = width - (xthick * 2);
dest.height = height - (ythick * 2);

if (dest.width < dest.height)
dest.x += 2;
else
dest.y += 2;

gdk_cairo_rectangle (cr, &dest);
cairo_clip (cr);

if (dest.width < dest.height)
{
_cairo_draw_line (cr, light, dest.x, dest.y, dest.x,
dest.height);
_cairo_draw_line (cr, dark, dest.x + (dest.width / 2),
dest.y, dest.x + (dest.width / 2), dest.height);
_cairo_draw_line (cr, shadow, dest.x + dest.width,
dest.y, dest.x + dest.width, dest.height);
}
else
{
_cairo_draw_line (cr, light, dest.x, dest.y,
dest.x + dest.width, dest.y);
_cairo_draw_line (cr, dark, dest.x,
dest.y + (dest.height / 2),
dest.x + dest.width, dest.y + (dest.height / 2));
_cairo_draw_line (cr, shadow, dest.x,
dest.y + dest.height, dest.x + dest.width,
dest.y + dest.height);
}

cairo_destroy (cr);
}
}

static void
Expand Down

0 comments on commit d8c2db3

Please sign in to comment.