#3 Edge copying, user data and graph event listeners

closed
nobody
None
5
2006-03-16
2005-07-29
John Gibson
No

Version 1.6.0

When copying edges from one graph to another listeners
receive the edge added notification before the user
data is copied. This makes it tricky to have a
listener that automatically copies edges added to one
graph to another.

Is this behavior intended? If so are there any
suggestions for workarounds?

Discussion

  • Joshua O'Madadhain

    Logged In: YES
    user_id=709417

    I'm not sure I follow you. f = e.copy(g) copies the user data from e to f first,
    and then adds the new edge f to the graph g, which triggers the listeners.
    That is, it appears that things happen in the order that you require.

    Do you have code that demonstrates this problem? If so, please supply a
    code snippet, annotated with notes on the specific behavior that you'd like to
    see, and what you're seeing instead.

    Joshua

     
  • John Gibson

    John Gibson - 2006-03-16

    Logged In: YES
    user_id=1320887

    I retested my code with 1.7.4 and it worked properly.

    In 1.6.0 the problem was in AbstractSparseEdge:
    public ArchetypeEdge copy(ArchetypeGraph newGraph)
    {
    ...
    ((Graph)newGraph).addEdge(e);
    e.importUserData(this);
    return e;
    }

    The listener is tripped on the addEdge() call, so then my
    listener would attempt to use the edge that was just added,
    but it couldn't reach the user data because it had not been
    copied yet. But all of this is moot because 1.7.4 fixed the
    problem.

     
  • John Gibson

    John Gibson - 2006-03-16
    • status: open --> closed
     

Log in to post a comment.