From 0adb37f2bb72bb13bbadde875077983e7904dbe0 Mon Sep 17 00:00:00 2001 From: David Capello Date: Mon, 2 Mar 2009 01:22:52 +0000 Subject: [PATCH] Fixed a bug with multiple editors, paste command, and cleaning the editor's cursor. --- ChangeLog | 6 ++++++ NEWS.txt | 1 + src/widgets/editor/cursor.cpp | 12 ++++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index fe08585f4..3824efe0f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-03-01 David A. Capello + + * src/widgets/editor/cursor.cpp (editor_clean_cursor): Fixed a + problem where old_clipping_region can be NULL if multiple editors + are in use and PASTE command is executed. + 2009-02-25 David A. Capello * src/commands/cmd_save_file.cpp (cmd_save_file_copy_as_execute): diff --git a/NEWS.txt b/NEWS.txt index 7b8a0d542..30327eb8e 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -7,6 +7,7 @@ NEWS + Added "Save Copy As" command (feature #2636076). + Fixed compilation support for gcc 64 bits. ++ Fixed a bug with multiple editors and paste command. 0.6.1 ----- diff --git a/src/widgets/editor/cursor.cpp b/src/widgets/editor/cursor.cpp index a5a117469..b09655bd0 100644 --- a/src/widgets/editor/cursor.cpp +++ b/src/widgets/editor/cursor.cpp @@ -65,6 +65,9 @@ static int cursor_negative; static int saved_pixel[MAX_SAVED]; static int saved_pixel_n; + +// These clipping regions are shared between all editors, so we cannot +// make assumptions about their old state static JRegion clipping_region; static JRegion old_clipping_region; @@ -156,6 +159,8 @@ void editor_draw_cursor(JWidget widget, int x, int y) editor->cursor_editor_y = y; /* save the clipping-region to know where to clean the pixels */ + if (old_clipping_region) + jregion_free(old_clipping_region); old_clipping_region = clipping_region; } @@ -194,7 +199,9 @@ void editor_clean_cursor(JWidget widget) editor->cursor_thick = 0; jregion_free(clipping_region); - jregion_free(old_clipping_region); + if (old_clipping_region) + jregion_free(old_clipping_region); + clipping_region = NULL; old_clipping_region = NULL; } @@ -361,7 +368,8 @@ static void cleanpixel(BITMAP *bmp, int x, int y, int color) if (saved_pixel_n < MAX_SAVED) { if (point_inside_region(x, y, clipping_region)) putpixel(bmp, x, y, saved_pixel[saved_pixel_n++]); - else if (point_inside_region(x, y, old_clipping_region)) + else if (old_clipping_region && + point_inside_region(x, y, old_clipping_region)) saved_pixel_n++; } }