Skip to content

Commit 44f09e7

Browse files
committed
fix load cancel
1 parent aa78bd2 commit 44f09e7

File tree

4 files changed

+21
-16
lines changed

4 files changed

+21
-16
lines changed

README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -236,17 +236,10 @@ On success, merge to master.
236236

237237
maybe check glib master and file a bug report
238238

239-
- load cancel does not work
240-
241-
- duplicate of a texture view crashes ... see tile_source_duplicate()
242-
243239
- check mem use, esp with three large images loaded
244240

245241
- PDF page change does not change image size if pages vary in size
246242

247-
- add some internal stuff, like pyramid shape, to props display? number of
248-
loaded tiles?
249-
250243
- ^C during a slow load leaves a file in /tmp, can we fix this?
251244

252245
- batch save?

src/imagewindow.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,9 @@ image_window_tile_source_changed(TileSource *tile_source, ImageWindow *win)
474474
printf("image_window_tile_source_changed:\n");
475475
#endif /*DEBUG*/
476476

477+
if (tile_source->load_error)
478+
image_window_set_error(win, tile_source->load_message);
479+
477480
state = g_variant_new_boolean(tile_source->falsecolour);
478481
change_state(GTK_WIDGET(win), "falsecolour", state);
479482

@@ -578,8 +581,6 @@ image_window_imageui_set_visible(ImageWindow *win,
578581
"visible", FALSE,
579582
NULL);
580583

581-
image_window_error_hide(win);
582-
583584
g_object_set(win->properties,
584585
"tile-source", new_tile_source,
585586
NULL);
@@ -725,10 +726,8 @@ image_window_cancel_clicked(GtkWidget *button, ImageWindow *win)
725726
VipsImage *image;
726727

727728
if ((tile_source = image_window_get_tile_source(win)) &&
728-
(image = tile_source_get_image(tile_source))) {
729-
printf("image_window_cancel_clicked: set kill on image %p\n", image);
729+
(image = tile_source_get_image(tile_source)))
730730
vips_image_set_kill(image, TRUE);
731-
}
732731
}
733732

734733
static void

src/tilesource.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ tile_source_dispose(GObject *object)
6363
VIPS_UNREF(tile_source->mask_region);
6464

6565
VIPS_FREE(tile_source->delay);
66+
VIPS_FREE(tile_source->load_message);
6667

6768
G_OBJECT_CLASS(tile_source_parent_class)->dispose(object);
6869
}
@@ -966,7 +967,7 @@ tile_source_init(TileSource *tile_source)
966967
tile_source->zoom = 1.0;
967968
}
968969

969-
static void
970+
static int
970971
tile_source_force_load(TileSource *tile_source)
971972
{
972973
if (tile_source->image_region &&
@@ -977,8 +978,11 @@ tile_source_force_load(TileSource *tile_source)
977978
rect.top = 0;
978979
rect.width = 1;
979980
rect.height = 1;
980-
(void) vips_region_prepare(tile_source->image_region, &rect);
981+
if (vips_region_prepare(tile_source->image_region, &rect))
982+
return -1;
981983
}
984+
985+
return 0;
982986
}
983987

984988
/* This runs in the main thread when the bg load is done. We can't use
@@ -1019,7 +1023,10 @@ tile_source_background_load_worker(void *data, void *user_data)
10191023

10201024
g_assert(tile_source->image_region);
10211025

1022-
tile_source_force_load(tile_source);
1026+
if (tile_source_force_load(tile_source)) {
1027+
tile_source->load_error = TRUE;
1028+
tile_source->load_message = vips_error_buffer_copy();
1029+
}
10231030

10241031
g_idle_add(tile_source_background_load_done_idle, tile_source);
10251032

src/tilesource.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,16 @@ typedef struct _TileSource {
190190
*/
191191
gboolean loaded;
192192

193-
/* TRUE when the imageis visible. GIF animations (for example) pause for
193+
/* TRUE when the image is visible. GIF animations (for example) pause for
194194
* invisible images.
195195
*/
196196
gboolean visible;
197+
198+
/* Set on a background load error, eg. cancel etc.
199+
*/
200+
int load_error;
201+
char *load_message;
202+
197203
} TileSource;
198204

199205
typedef struct _TileSourceClass {

0 commit comments

Comments
 (0)