Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 258275 - Exception after direct text label editing if zoom level is not 100%
Summary: Exception after direct text label editing if zoom level is not 100%
Status: RESOLVED FIXED
Alias: None
Product: GMF-Tooling
Classification: Modeling
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows XP
: P3 major with 2 votes (vote)
Target Milestone: 2.3   Edit
Assignee: Artem Tikhomirov CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-10 07:48 EST by Christoph Weckerle CLA
Modified: 2010-07-19 12:19 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christoph Weckerle CLA 2008-12-10 07:48:54 EST
Build ID: M20080911-1700

Steps To Reproduce:
1. Change the diagram zoom level to anything but 100%.
2. Perform direct editing on any modifiable text label which does NOT wrap(!).
3. Stop editing (it does not matter if changes are accepted or not).

-> An "Unhandled event loop exception" is reported in the Error Log view, and the edited label figure is garbled.

Exception message excerpt:

java.lang.IllegalArgumentException: Argument not valid
	at org.eclipse.swt.SWT.error(SWT.java:3761)
	at org.eclipse.swt.SWT.error(SWT.java:3695)
	at org.eclipse.swt.SWT.error(SWT.java:3666)
	at org.eclipse.swt.graphics.GC.setFont(GC.java:4156)
	at org.eclipse.draw2d.FigureUtilities.setFont(FigureUtilities.java:329)
	at org.eclipse.draw2d.FigureUtilities.getFontMetrics(FigureUtilities.java:58)
	at XYZEditPartFactory$TextCellEditorLocator.relocate(XYZEditPartFactory.java:156)
	at ...

More information:
It seems that the Font instance used by the Text control of the TextCellEditor has been disposed when the the FigureUtilities.getFontMetrics() method is invoked within the GMF generated TextCellEditorLocator.relocate() method, which finally causes the aforementioned exception to be thrown. Strangely this is not the case when the zoom level is 100%.

(The closed bug #168199 describes the same or a similar issue.)
Comment 1 Alex Shatalin CLA 2009-05-28 14:35:41 EDT
I can not reproduce this problem neither with GMF 2.1 nor with the current state.

Do you see this exception in .log file?

I've used Ecore diagram example to check this problem
Comment 2 Romain Raugi CLA 2009-08-28 05:17:12 EDT
Build ID: 20090619-0625

I also reproduced it with:

* Windows XP SP2
* GMF 2.2

- Create a UML 2.1 Class Diagram
- Set the zoom level to 75% for example
- Create 2 classes
- Create an Association between them
- When you're prompted for a text, press enter (or enter a text and press enter).

The exception appears in the error log.
Comment 3 Miro Spoenemann CLA 2009-12-23 05:58:57 EST
This bug *always* occurs with our own generated editor. As a workaround, I changed the generation template for EditPartFactory, in the relocate method of the nested TextCellEditorLocator class:

org.eclipse.swt.graphics.Font font = text.getFont();
if (!font.isDisposed()) {
	int avr = org.eclipse.draw2d.FigureUtilities
		.getFontMetrics(font).getAverageCharWidth();
	rect.setSize(new org.eclipse.draw2d.geometry.Dimension(
		text.computeSize(org.eclipse.swt.SWT.DEFAULT,
		org.eclipse.swt.SWT.DEFAULT)).expand(avr * 2, 0));
}

The relevant change is the added check for font.isDisposed().
Comment 4 Rainer Ganß CLA 2010-02-18 08:17:46 EST
The Bug is still open so;

@Alex. Did you edit the laben direct in the editor? Not in the Properties View!

@Miro. Your Workarround works fine for me!
Comment 5 Thiébaut Champenier CLA 2010-03-05 09:23:17 EST
> @Alex. Did you edit the laben direct in the editor? Not in the Properties View!

Yes, in the editor with direct-edit (pressing F2 for example).

As of GMF 2.2.2 the bug is still here, reproducible 100% of the time.
Comment 6 Artem Tikhomirov CLA 2010-03-08 16:41:12 EST
This is generation counterpart of the bug #279788. Suggested fix (check for font.isDisposed) was added to EditPartFactory template.
Comment 7 Eclipse Webmaster CLA 2010-07-16 23:38:26 EDT
[target cleanup] 2.3 M6 was the original target milestone for this
bug
Comment 8 Eclipse Webmaster CLA 2010-07-19 12:19:19 EDT
[GMF Restructure] Bug 319140 : product GMF and component
Templates was the original product and component for this bug