URI:
       tI *think* the colormap needs to be unref'd... - croptool - Image cropping tool
  HTML git clone git://lumidify.org/croptool.git
   DIR Log
   DIR Files
   DIR Refs
   DIR README
       ---
   DIR commit 7b475e359390e105c01d69cdc572bbee1bcb9ce8
   DIR parent e6ff02791e78f0547c1e07f9faad425553fa1b35
  HTML Author: lumidify <nobody@lumidify.org>
       Date:   Thu, 16 Apr 2020 14:30:23 +0200
       
       I *think* the colormap needs to be unref'd...
       
       Diffstat:
         M croptool.c                          |      17 +++++++++--------
       
       1 file changed, 9 insertions(+), 8 deletions(-)
       ---
   DIR diff --git a/croptool.c b/croptool.c
       t@@ -141,11 +141,12 @@ int main(int argc, char *argv[]) {
                GdkColormap *cmap = gdk_drawable_get_colormap(area->window);
                gdk_colormap_alloc_color(cmap, &state->gdk_color, FALSE, TRUE);
                gdk_color_parse(SELECTION_COLOR, &state->gdk_color);
       +        g_object_unref(cmap);
        
                gtk_main();
        
                for (int i = 0; i < argc; i++) {
       -                if (state->selections[i] != NULL) {
       +                if (state->selections[i]) {
                                print_selection(state->selections[i], argv[i]);
                                free(state->selections[i]);
                        }
       t@@ -205,7 +206,7 @@ load_pixbuf(char *filename, int w, int h, int *actual_w, int *actual_h) {
                h = h < *actual_h || *actual_h < 0 ? h : *actual_h;
                GError *err = NULL;
                GdkPixbuf *pix = gdk_pixbuf_new_from_file_at_size(filename, w, h, &err);
       -        if (err != NULL) {
       +        if (err) {
                        fprintf(stderr, "%s\n", err->message);
                        g_error_free(err);
                        return NULL;
       t@@ -248,7 +249,7 @@ collide_rect(int x, int y, struct Rect rect) {
        static gboolean
        button_press(GtkWidget *area, GdkEventButton *event, gpointer data) {
                struct State *state = (struct State *)data;
       -        if (state->cur_selection < 0 || state->selections[state->cur_selection] == NULL)
       +        if (state->cur_selection < 0 || !state->selections[state->cur_selection])
                        return FALSE;
                struct Rect *rect = &state->selections[state->cur_selection]->rect;
                gint x = event->x;
       t@@ -343,7 +344,7 @@ configure_event(GtkWidget *area, GdkEvent *event, gpointer data) {
        static gboolean
        draw_expose(GtkWidget *area, GdkEvent *event, gpointer data) {
                struct State *state = (struct State *)data;
       -        if (state->cur_selection < 0 || state->selections[state->cur_selection] == NULL)
       +        if (state->cur_selection < 0 || !state->selections[state->cur_selection])
                        return FALSE;
                redraw(area, state);
                return FALSE;
       t@@ -352,7 +353,7 @@ draw_expose(GtkWidget *area, GdkEvent *event, gpointer data) {
        static gboolean
        drag_motion(GtkWidget *area, GdkEventMotion *event, gpointer data) {
                struct State *state = (struct State *)data;
       -        if (state->cur_selection < 0 || state->selections[state->cur_selection] == NULL)
       +        if (state->cur_selection < 0 || !state->selections[state->cur_selection])
                        return FALSE;
                struct Rect *rect = &state->selections[state->cur_selection]->rect;
                gint x = event->x;
       t@@ -400,7 +401,7 @@ change_picture(
                int new_selection, int orig_w, int orig_h,
                struct State *state, gboolean copy_box) {
        
       -        if (state->cur_pixbuf != NULL) {
       +        if (state->cur_pixbuf) {
                        g_object_unref(G_OBJECT(state->cur_pixbuf));
                        state->cur_pixbuf = NULL;
                }
       t@@ -444,7 +445,7 @@ next_picture(GtkWidget *area, struct State *state, gboolean copy_box) {
                int tmp_cur_selection = state->cur_selection;
                int orig_w, orig_h;
                /* loop until we find a loadable file */
       -        while (tmp_pixbuf == NULL && tmp_cur_selection + 1 < state->num_files) {
       +        while (!tmp_pixbuf && tmp_cur_selection + 1 < state->num_files) {
                        tmp_cur_selection++;
                        tmp_pixbuf = load_pixbuf(
                            state->filenames[tmp_cur_selection],
       t@@ -463,7 +464,7 @@ last_picture(GtkWidget *area, struct State *state) {
                int tmp_cur_selection = state->cur_selection;
                int orig_w, orig_h;
                /* loop until we find a loadable file */
       -        while (tmp_pixbuf == NULL && tmp_cur_selection > 0) {
       +        while (!tmp_pixbuf && tmp_cur_selection > 0) {
                        tmp_cur_selection--;
                        tmp_pixbuf = load_pixbuf(
                            state->filenames[tmp_cur_selection],