Skip to content

Commit 46dff32

Browse files
committed
fix control bar on page flip
1 parent 98b7130 commit 46dff32

File tree

5 files changed

+31
-55
lines changed

5 files changed

+31
-55
lines changed

README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,6 @@ On success, merge to master.
232232

233233
- duplicate could copy zoom/pan settings
234234

235-
- next image twice ... display bar stops working
236-
237235
- get `object_unref: assertion 'G_IS_OBJECT (object)' failed` during free of
238236
stack ... seems to be a harmless minor glib bug with `g_clear_object()`
239237
failing with a crit for a null value
@@ -242,11 +240,7 @@ On success, merge to master.
242240

243241
- load cancel does not work
244242

245-
- duplicate should copy more view params? slider settings? scale and
246-
position?
247-
248-
- looks like duplicate of a texture view will fail ... see
249-
tile_source_duplicate()
243+
- duplicate of a texture view crashes ... see tile_source_duplicate()
250244

251245
- check mem use, esp with three large images loaded
252246

src/displaybar.c

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct _Displaybar {
1212
*/
1313
ImageWindow *win;
1414

15-
/* The tile_source we are currently controlling. Not a ref.
15+
/* A ref to the tile_source we are currently controlling.
1616
*/
1717
TileSource *tile_source;
1818

@@ -43,8 +43,10 @@ static void
4343
displaybar_tile_source_changed(TileSource *tile_source, Displaybar *displaybar)
4444
{
4545
#ifdef DEBUG
46-
#endif /*DEBUG*/
4746
printf("displaybar_tile_source_changed:\n");
47+
#endif /*DEBUG*/
48+
49+
g_assert(tile_source == displaybar->tile_source);
4850

4951
if (TSLIDER(displaybar->scale)->value != tile_source->scale) {
5052
TSLIDER(displaybar->scale)->value = tile_source->scale;
@@ -70,6 +72,8 @@ displaybar_page_changed(TileSource *tile_source, Displaybar *displaybar)
7072
printf("displaybar_page_changed:\n");
7173
#endif /*DEBUG*/
7274

75+
g_assert(tile_source == displaybar->tile_source);
76+
7377
gtk_spin_button_set_value(GTK_SPIN_BUTTON(displaybar->page),
7478
tile_source->page);
7579
}
@@ -82,7 +86,7 @@ displaybar_disconnect(Displaybar *displaybar)
8286
FREESID(displaybar->tiles_changed_sid, displaybar->tile_source);
8387
FREESID(displaybar->page_changed_sid, displaybar->tile_source);
8488

85-
displaybar->tile_source = NULL;
89+
VIPS_UNREF(displaybar->tile_source);
8690
}
8791
}
8892

@@ -91,28 +95,33 @@ displaybar_disconnect(Displaybar *displaybar)
9195
static void
9296
displaybar_image_window_changed(ImageWindow *win, Displaybar *displaybar)
9397
{
94-
TileSource *tile_source = image_window_get_tile_source(win);
95-
9698
#ifdef DEBUG
97-
#endif /*DEBUG*/
9899
printf("displaybar_image_window_changed:\n");
100+
#endif /*DEBUG*/
99101

100102
displaybar_disconnect(displaybar);
101103

102-
if (tile_source) {
103-
displaybar->changed_sid = g_signal_connect(tile_source,
104+
TileSource *new_tile_source = image_window_get_tile_source(win);
105+
if (new_tile_source) {
106+
/* Set new source.
107+
*/
108+
displaybar->changed_sid = g_signal_connect(new_tile_source,
104109
"changed",
105110
G_CALLBACK(displaybar_tile_source_changed), displaybar);
106-
displaybar->tiles_changed_sid = g_signal_connect(tile_source,
111+
displaybar->tiles_changed_sid = g_signal_connect(new_tile_source,
107112
"tiles-changed",
108113
G_CALLBACK(displaybar_tile_source_changed), displaybar);
109-
displaybar->page_changed_sid = g_signal_connect(tile_source,
114+
displaybar->page_changed_sid = g_signal_connect(new_tile_source,
110115
"page-changed",
111116
G_CALLBACK(displaybar_page_changed), displaybar);
112117

113-
displaybar->tile_source = tile_source;
118+
displaybar->tile_source = new_tile_source;
119+
g_object_ref(new_tile_source);
114120

115-
displaybar_tile_source_changed(tile_source, displaybar);
121+
/* Init from new source.
122+
*/
123+
displaybar_tile_source_changed(new_tile_source, displaybar);
124+
displaybar_page_changed(new_tile_source, displaybar);
116125
}
117126
}
118127

@@ -122,11 +131,12 @@ displaybar_set_image_window(Displaybar *displaybar, ImageWindow *win)
122131
/* No need to ref ... win holds a ref to us.
123132
*/
124133
displaybar->win = win;
125-
displaybar->tile_source = image_window_get_tile_source(win);
126134

127135
g_signal_connect_object(win, "changed",
128136
G_CALLBACK(displaybar_image_window_changed),
129137
displaybar, 0);
138+
139+
displaybar_image_window_changed(win, displaybar);
130140
}
131141

132142
static void

src/imagewindow.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ G_DEFINE_TYPE(ImageWindow, image_window, GTK_TYPE_APPLICATION_WINDOW);
7070
/* Our signals.
7171
*/
7272
enum {
73-
SIG_CHANGED, /* A new imageui */
73+
SIG_CHANGED, /* A new imageui and tile_source */
7474
SIG_STATUS_CHANGED, /* New mouse position */
7575
SIG_LAST
7676
};
@@ -174,11 +174,6 @@ image_window_active_remove(ImageWindow *win, const char *filename)
174174
if (active->imageui == win->imageui)
175175
win->imageui = NULL;
176176

177-
// gtk hates killing widgets with active focus ... this triggers crashes
178-
// in focus decoration redraw
179-
gtk_widget_grab_focus(GTK_WIDGET(win->gears));
180-
181-
printf("image_window_active_remove: %s\n", filename);
182177
gtk_stack_remove(GTK_STACK(win->stack), GTK_WIDGET(active->imageui));
183178
g_hash_table_remove(win->active_hash, filename);
184179
}
@@ -199,8 +194,6 @@ image_window_active_add(ImageWindow *win,
199194
{
200195
g_assert(!image_window_active_lookup(win, filename));
201196

202-
printf("image_window_active_add: %s\n", filename);
203-
204197
Active *active = VIPS_NEW(NULL, Active);
205198
active->win = win;
206199
active->filename = filename;
@@ -581,11 +574,6 @@ image_window_imageui_set_visible(ImageWindow *win,
581574
VipsImage *image;
582575
char *title;
583576

584-
/* Try to shut down any current evaluation.
585-
*/
586-
if (old_tile_source)
587-
tile_source_kill(old_tile_source);
588-
589577
g_object_set(old_tile_source,
590578
"visible", FALSE,
591579
NULL);
@@ -648,7 +636,7 @@ image_window_imageui_set_visible(ImageWindow *win,
648636
// not a ref, so we can just overwrite it
649637
win->imageui = imageui;
650638

651-
// update the displaybar etc.
639+
// tell everyone there's a new imageui
652640
image_window_changed(win);
653641

654642
// update the menus

src/tilesource.c

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -587,11 +587,15 @@ tile_source_rgb_image(TileSource *tile_source, VipsImage *in)
587587
}
588588

589589
/* Rebuild just the second half of the image pipeline, eg. after a change to
590-
* falsecolour, or if current_z changes.
590+
* falsecolour, scale, or if current_z changes.
591591
*/
592592
static int
593593
tile_source_update_rgb(TileSource *tile_source)
594594
{
595+
#ifdef DEBUG
596+
printf("tile_source_update_rgb:\n");
597+
#endif /*DEBUG*/
598+
595599
if (tile_source->display) {
596600
VipsImage *rgb;
597601

@@ -1757,9 +1761,6 @@ tile_source_fill_tile(TileSource *tile_source, Tile *tile)
17571761
tile->region->valid.left, tile->region->valid.top);
17581762
#endif /*DEBUG_VERBOSE*/
17591763

1760-
if (tile_source->kill)
1761-
return 0;
1762-
17631764
/* Change z if necessary.
17641765
*/
17651766
if (tile_source->current_z != tile->z ||
@@ -1904,15 +1905,3 @@ tile_source_duplicate(TileSource *tile_source)
19041905
return new_tile_source;
19051906
}
19061907

1907-
void
1908-
tile_source_kill(TileSource *tile_source)
1909-
{
1910-
tile_source->kill = TRUE;
1911-
1912-
if (tile_source->display)
1913-
vips_image_set_kill(tile_source->display, TRUE);
1914-
if (tile_source->mask)
1915-
vips_image_set_kill(tile_source->mask, TRUE);
1916-
if (tile_source->rgb)
1917-
vips_image_set_kill(tile_source->rgb, TRUE);
1918-
}

src/tilesource.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,6 @@ typedef struct _TileSource {
194194
* invisible images.
195195
*/
196196
gboolean visible;
197-
198-
/* Set this to try to shut down eval.
199-
*/
200-
gboolean kill;
201197
} TileSource;
202198

203199
typedef struct _TileSourceClass {
@@ -250,6 +246,5 @@ gboolean tile_source_get_pixel(TileSource *tile_source,
250246
int image_x, int image_y, double **vector, int *n);
251247
TileSource *tile_source_duplicate(TileSource *tile_source);
252248
void tile_source_changed(TileSource *tile_source);
253-
void tile_source_kill(TileSource *tile_source);
254249

255250
#endif /*__TILE_SOURCE_H*/

0 commit comments

Comments
 (0)