Skip to content

Commit

Permalink
Fixed (hopefully) stupid garbage collection mistake I made
Browse files Browse the repository at this point in the history
  • Loading branch information
Guff committed Jan 16, 2012
1 parent 4951004 commit 4fe6043
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand Down
9 changes: 6 additions & 3 deletions clib/style.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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),
Expand Down
5 changes: 1 addition & 4 deletions drawing.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions lualock.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <errno.h>

#define PW_BUFF_SIZE 32
#define DEFAULT_FONT "Sans 12"

#include "lualock.h"
#include "misc.h"
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion lualock.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
#include <lua.h>
#include <gdk/gdk.h>

#define DEFAULT_FONT "Sans 12"

typedef struct {
const gchar *font;
PangoFontDescription *font_desc;

gint x;
gint y;
Expand Down

0 comments on commit 4fe6043

Please sign in to comment.