XPCE: Deleting member from a chain leaving floating pointer? Or, deleting dialog objects

I have an application I’m trying to write that involves a modular dialog. I want to be able to remove an object from the dialog dynamically without affecting other objects, but having layout cascade. However, send(Dialog, delete, Obj) leaves a gap, as does deleting from the chain. I’ve tried to get around this by deleting the object from the chain and clearing the dialog and then appending back every item in the dialog. This doesn’t seem to help much either, since deleting the first object now cascades only the second object for some reason, still unsure as to why. It seems like there must be some floating pointers left behind in chain somehow. Is my only reliable option for managing dynamic dialogs to do manual placements?

This is the code I’m currently looking at and I am really not happy with it since it is buggy and does not seem very elegant. I cannot find much in the xpce user guide about this.

    get(Dialog, size, Size),
    get(Size, width, W),
    get(Size, height, H),
    send(Dialog, size, size(W, H-120)),
    get(Dialog, members, Chain),
    send(Chain, delete, Group),
    send(Group, for_all, message(Group, delete, @arg1)),
    chain_list(Chain, L),
    send(Dialog, clear),
    send(Chain, clear),
    %% send(Chain, for_all, message(@prolog, format, '~w\n', @arg1)),
    forall(member(X, L),
            send(Dialog, append, X)),
    send(Dialog, compute),
    send(Dialog, fit),
    send(Dialog, layout).

It is incomplete code, which makes it even harder to judge. xpce is over 30 years old technology that hasn’t been touched in any major way for a very long time :frowning: Surely you should not manipulate the members chain of a dialog directly. You can probably send a destroy to the thing you want removed. If you use its automatic layout, you’ll have to relink the above/below relations. I guess by first getting the thing above and below, then destroy the object and then send the thing below that is it below the thing above and finally refit the layout. Surely it was never designed to be used that way :slight_smile:

1 Like