Jarda Benkovsky wrote: > 2) Layer dialog does not redraw > > Maybe this one is known: open layer dialog, create new layer in the > image, > paste something, anchor floating selection to the layer and lo! the > layer > preview does not redraw and the layer appears to be empty still. > GimpDrawables contain lists of small pixmaps to refresh the tiny preview clips in layer widgets or the gimp image selector. (GSList GimpDrawable::preview_cache). Clearly, any operation that disturbs a drawable causes the need to regenerate the pixmaps on this list. In most cases, it seems this goal can be reached by calls to gimp_drawable_invalidate(GimpDrawable *), followed by gdisplay_flush() as a kind of post-edit cleanup protocol. The first routine resets a flag in the GimpDrawable (gboolean GimpDrawable::preview_valid = FALSE), the second creates a slurry of gtk refresh display events; Layers & Channel callbacks connecting the Layer widget to these events invoke redrawing routines, in particular, layer_widget_preview_events(). This callback polls preview_valid and if it has been reset, regenerates the list of pixmap caches in the drawable. This post-edit protocol has a variant; given a layer and a "damage rectangle" known to fully cover changes to a layer, drawable_update() may be substituted for gimp_drawable_invalidate(), which it invokes internally. The floating selection is a special kind of layer and exception code provides a good deal of specialized handling for these specimens. In particular, the callback for the anchor button invokes floating_sel_anchor() [line 101, floating_sel.c CVS 1.15] to composite the floating selection layer with the layer it has been associated with - typically the selected layer when the user had invoked the paste. This code naturally does not prime the floating selection layer to undergo the post-edit cleanup protocol - it will delete the floating selection layer following compositing anyway. Nor does version 1.15 invoke the post-edit cleanup protocol on the associated layer; this appears to be an accidental oversight. On first blush, gimage_mask_invalidate(), called by floating_sel_anchor(), seems to supply a similar post-edit cleanup call; that routine invokes drawable_update() on the floating section(if it exists); but at that juncture, the floating selection has been removed and, in any case, the invocation of drawable_update() is not on the underlying associated layer. It seems then, that no agent ever resets GimpDrawable::preview_valid in the associated (and now composited) layer. With the flag remaining set, layer_widget_preview_events() has no cause to regenerate the list of pixmap caches when it services events on the layer widget that previews the associated layer in the Layers & Channels dialog box. There seems a number of ways to remedy this oversight; In the CVS 1.15 version of floating_sel_anchor(), I've elected to invoke gimage_mask_invalidate() on the associated layer, after the undo push but before compositing begins, using the pointer reference to it in the fs substructure of the floating layer - see the associated patch. Maintainers of gimp/app may have better reasons to put this call elsewhere or take diffeent approaches, but I've observed no peculiarities on testing to date and the preview image now accurately tracks the content of the layer following the anchoring of pastes. Garry R. Osgood --- floating_sel_old.c Fri Sep 10 20:30:32 1999 +++ floating_sel.c Fri Sep 10 18:14:56 1999 @@ -113,6 +113,10 @@ /* Start a floating selection anchoring undo */ undo_push_group_start (gimage, FS_ANCHOR_UNDO); + /* Invalidate the previews of the layer that will be composited with the floating section. */ + + drawable_invalidate_preview (layer->fs.drawable); + /* Relax the floating selection */ floating_sel_relax (layer, TRUE);