Skip to main content



      Home
Home » Modeling » Graphiti » Problem due to commit 4364ec2 (EmfService.isisObjectAlive)
Problem due to commit 4364ec2 (EmfService.isisObjectAlive) [message #1720316] Sat, 16 January 2016 16:11 Go to next message
Eclipse UserFriend
I recently merged latest Graphiti master tree (2015-12-22) with my own sources, and experienced a problem in my graphical editor.

After a good deal of researching, I found that the culprit was in commit 4364ec2 (2015-10-15), specifically in the modification of EmfService.isisObjectAlive method, that was proposed here

https://bugs.eclipse.org/bugs/show_bug.cgi?id=423018#c11

"If it has no side effect elsewhere"... Well, for me, it had.

I had a method that dynamically adds/removes a child GA, from a parent. This occurs in the context of some XXXCustomFeature.execute() call, and it's followed by a layoutPictogramElement() and an editor refresh

The problem is that now the "remove" does not work. It basically does this:

	Ellipse circle = null;
	for (GraphicsAlgorithm ga : parentGa.getGraphicsAlgorithmChildren()) {
			if (ga instanceof Ellipse) {
				circle = (Ellipse) ga;
				break;
			}
	}
	if (circle != null)
			parentGa.getGraphicsAlgorithmChildren().remove(circle);
  


But the removed GA is still shown. The problem is fixed if I revert to the old version, and consider an EObject "not alive" if its eResource is null.

public boolean isObjectAlive(EObject obj) {
		return obj != null && obj.eResource() != null;
}


I'm not sure of the internals, and what is exactly the concept of "Alive Object". I see that when I add the GA the method is not called, and when I delete it it's called twice (4 times if I return "alive"), I copy below the stacktraces.

Regards

Hernan

--------------

Thread [main] (Suspended (breakpoint at line 38 in EmfService))	
	owns: GFWorkspaceCommandStackImpl  (id=113)	
	EmfService.isObjectAlive(EObject) line: 38	
	AnchorContainerDelegate(PictogramElementDelegate).isRefreshPossible(PictogramElement) line: 1203	
	AnchorContainerDelegate(PictogramElementDelegate).refreshFigureForEditPart() line: 356	
	ShapeEditPart.refreshVisuals() line: 704	
	ShapeEditPart(AbstractEditPart).refresh() line: 725	
	ShapeEditPart(AbstractGraphicalEditPart).refresh() line: 644	
	ShapeEditPart.refresh() line: 596	
	AnchorContainerDelegate(PictogramElementDelegate).refreshEditPartsForModelChildrenAndSourceConnections(EditPart) line: 319	
	ContainerShapeEditPart(ShapeEditPart).refreshChildren() line: 685	
	ContainerShapeEditPart(AbstractEditPart).refresh() line: 726	
	ContainerShapeEditPart(AbstractGraphicalEditPart).refresh() line: 644	
	ContainerShapeEditPart(ShapeEditPart).refresh() line: 596	
	AnchorContainerDelegate(PictogramElementDelegate).refreshEditPartsForModelChildrenAndSourceConnections(EditPart) line: 319	
	DiagramEditPart(ShapeEditPart).refreshChildren() line: 685	
	DiagramEditPart(AbstractEditPart).refresh() line: 726	
	DiagramEditPart(AbstractGraphicalEditPart).refresh() line: 644	
	DiagramEditPart(ShapeEditPart).refresh() line: 596	
	DiagramEditPart.refresh() line: 189	
   ...

Thread [main] (Suspended (breakpoint at line 38 in EmfService))	
	owns: EMFOperationTransaction  (id=631)	
	owns: GFWorkspaceCommandStackImpl  (id=113)	
	EmfService.isObjectAlive(EObject) line: 38	
	DiagramChangeListener.resourceSetChanged(ResourceSetChangeEvent) line: 116	
	TransactionalEditingDomainImpl$1.run() line: 781	
	TransactionalEditingDomainImpl.runExclusive(Runnable) line: 328	
	TransactionalEditingDomainImpl.postcommit(InternalTransaction) line: 771	
	TransactionalEditingDomainImpl.deactivate(InternalTransaction) line: 543	
	EMFOperationTransaction(TransactionImpl).close() line: 712	
	EMFOperationTransaction(TransactionImpl).commit() line: 474	
	EMFCommandOperation(AbstractEMFOperation).execute(IProgressMonitor, IAdaptable) line: 155	
	DefaultOperationHistory.execute(IUndoableOperation, IProgressMonitor, IAdaptable) line: 516	
	GFWorkspaceCommandStackImpl(WorkspaceCommandStackImpl).doExecute(Command, Map<?,?>) line: 208	
	GFWorkspaceCommandStackImpl(AbstractTransactionalCommandStack).execute(Command, Map<?,?>) line: 165	
	GFWorkspaceCommandStackImpl.execute(Command, Map<?,?>) line: 96	
	GFCommandStack.execute(Command) line: 138	
	CustomAction.executeOnCommandStack(ICommand) line: 65	
	CustomAction.run() line: 60	
	CustomAction(Action).runWithEvent(Event) line: 473	
	ActionContributionItem.handleWidgetSelection(Event, boolean) line: 595	
   ...
Re: Problem due to commit 4364ec2 (EmfService.isisObjectAlive) [message #1720433 is a reply to message #1720316] Mon, 18 January 2016 10:52 Go to previous messageGo to next message
Eclipse UserFriend
Hernan,

thanks for bringing this up. Could you please file a new Bugzilla to track this?

Thanks,
Michael
Re: Problem due to commit 4364ec2 (EmfService.isisObjectAlive) [message #1720439 is a reply to message #1720433] Mon, 18 January 2016 11:12 Go to previous messageGo to next message
Eclipse UserFriend
Done

https://bugs.eclipse.org/bugs/show_bug.cgi?id=486051

For the record: I experience the problem not only with the above GA removal, but with other removals.

Even worse, what happens is, not only that the removed GA are still displayed, but my business objects EMF container relationships gets corrupted.

Re: Problem due to commit 4364ec2 (EmfService.isisObjectAlive) [message #1724625 is a reply to message #1720439] Wed, 24 February 2016 16:46 Go to previous messageGo to next message
Eclipse UserFriend
I'm having the same issue. For me it's a ChopBoxAnchor that is causing an NPE in DiagramChangeListener.resourceSetChanged(ResourceSetChangeEvent event). The anchor is removed from its parent (a ContainerShape) and its eContainer is null, therefore the eResource is null. This causes an NPE in DiagramChangeListener.calculateActiveContainerPe(EObject affectedElement) because its parent is null.
Re: Problem due to commit 4364ec2 (EmfService.isisObjectAlive) [message #1724756 is a reply to message #1724625] Thu, 25 February 2016 13:03 Go to previous messageGo to next message
Eclipse UserFriend
Not sure if this will help anyone else, but I was able to cobble together a kludgy workaround for my use case (deleting a ChopboxAnchor) by overriding DiagramChangeListener in my DiagramBehavior implementation:

DiagramChangeListener diagramChangeListener;

@Override
protected void registerDiagramResourceSetListener() {
diagramChangeListener = new DiagramChangeListener(this) {

public NotificationFilter getFilter() {
return new NotificationFilter.Custom() {

@Override
public boolean matches(Notification notification) {
Object notifier = notification.getNotifier();
if (notifier instanceof ChopboxAnchor) {
ChopboxAnchor anchor = (ChopboxAnchor) notifier;
if (anchor.getParent()==null)
return false;
}
return !notification.isTouch();
}

};
}

};
TransactionalEditingDomain eDomain = getEditingDomain();
eDomain.addResourceSetListener(diagramChangeListener);
}

protected void unregisterDiagramResourceSetListener() {
if (diagramChangeListener != null) {
diagramChangeListener.stopListening();
TransactionalEditingDomain editingDomain = getEditingDomain();
if (editingDomain != null) {
editingDomain.removeResourceSetListener(diagramChangeListener);
}
}
}
Re: Problem due to commit 4364ec2 (EmfService.isisObjectAlive) [message #1724849 is a reply to message #1724756] Fri, 26 February 2016 09:24 Go to previous message
Eclipse UserFriend
Robert,

thanks for this workaround, I just brought the fix on the way. I reverted back to the original behavior of EMFService.isAlive. That change will become effective with Neon M6. See the linked bugzilla https://bugs.eclipse.org/bugs/show_bug.cgi?id=486051.

Michael
Previous Topic:Resource problem in EMF Generated and Graphiti Editor
Next Topic:removing shape with attached connection issue
Goto Forum:
  


Current Time: Tue Apr 29 00:58:40 EDT 2025

Powered by FUDForum. Page generated in 0.09419 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top