From 4fe6043c75edbd81d089cbbc590effd7fad1a879 Mon Sep 17 00:00:00 2001 From: Guff Date: Sun, 15 Jan 2012 20:59:00 -0500 Subject: [PATCH] Fixed (hopefully) stupid garbage collection mistake I made --- Makefile | 3 +-- clib/style.c | 9 ++++++--- drawing.c | 5 +---- lualock.c | 3 +-- lualock.h | 4 +++- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index b0dc041..f5e6a1f 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ INSTALLDIR := $(DESTDIR)$(PREFIX) CC := gcc -PKGS := gtk+-3.0 lua oocairo xscrnsaver +PKGS := gtk+-3.0 lua oocairo xscrnsaver x11 INCS := $(shell pkg-config --cflags $(PKGS)) LIBS := $(shell pkg-config --libs $(PKGS)) -lpam @@ -17,7 +17,6 @@ SRCS := $(wildcard *.c clib/*.c) HEADS := $(wildcard *.h clib/*.h) OBJS := $(foreach obj,$(SRCS:.c=.o),$(obj)) - all: options lualock debug: CFLAGS += $(DEBUG) diff --git a/clib/style.c b/clib/style.c index 1951d93..0e32e51 100644 --- a/clib/style.c +++ b/clib/style.c @@ -25,8 +25,11 @@ void style_set(const gchar *font, gint x, gint y, gint off_x, gint off_y, gint width, gint height, gdouble r, gdouble g, gdouble b, gdouble a) { - if (font) - lualock.style.font = font; + if (font) { + pango_font_description_free(lualock.style.font_desc); + lualock.style.font_desc = pango_font_description_from_string(font); + } + lualock.style.x = x; lualock.style.y = y; lualock.style.off_x = off_x; @@ -56,7 +59,7 @@ int lualock_lua_style_set(lua_State *L) { lua_getfield(L, 1, "width"); lua_getfield(L, 1, "height"); - style_set(luaL_optstring(L, 2, lualock.style.font), + style_set(luaL_optstring(L, 2, DEFAULT_FONT), luaL_optnumber(L, 3, lualock.style.x), luaL_optnumber(L, 4, lualock.style.y), luaL_optnumber(L, 5, lualock.style.off_x), diff --git a/drawing.c b/drawing.c index 89575ea..8804298 100644 --- a/drawing.c +++ b/drawing.c @@ -45,10 +45,7 @@ void draw_password_mask(void) { PangoLayout *layout = pango_cairo_create_layout(cr); - PangoFontDescription *desc = - pango_font_description_from_string(lualock.style.font); - pango_layout_set_font_description(layout, desc); - pango_font_description_free(desc); + pango_layout_set_font_description(layout, lualock.style.font_desc); cairo_set_source_rgba(cr, lualock.style.r, lualock.style.g, lualock.style.b, lualock.style.a); cairo_move_to(cr, lualock.style.off_x, lualock.style.off_y); diff --git a/lualock.c b/lualock.c index 6ef3668..d90c15b 100644 --- a/lualock.c +++ b/lualock.c @@ -30,7 +30,6 @@ #include #define PW_BUFF_SIZE 32 -#define DEFAULT_FONT "Sans 12" #include "lualock.h" #include "misc.h" @@ -88,7 +87,7 @@ static void init_timers(void) { } static void init_style(void) { - lualock.style.font = DEFAULT_FONT; + lualock.style.font_desc = pango_font_description_from_string(DEFAULT_FONT); lualock.style.x = 400; lualock.style.y = 540; lualock.style.off_x = 5; diff --git a/lualock.h b/lualock.h index 234fe38..c6aea89 100644 --- a/lualock.h +++ b/lualock.h @@ -22,8 +22,10 @@ #include #include +#define DEFAULT_FONT "Sans 12" + typedef struct { - const gchar *font; + PangoFontDescription *font_desc; gint x; gint y;