Bug 36876 - CView makes ClassCastException when exiting workbench
Summary: CView makes ClassCastException when exiting workbench
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-core (show other bugs)
Version: 2.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Alain Magloire CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-04-25 04:06 EDT by Martin Lescuyer CLA
Modified: 2009-01-09 14:53 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Lescuyer CLA 2003-04-25 04:06:46 EDT
Hi,

In method org.eclipse.cdt.internal.ui.cview.CView.saveState(IMemento), called 
when exiting the workbench, line 1284, the selected elements of the tree viewer 
is systematically casted into ICElement, which causes an exception if for 
example, an a.txt file is selected. 

Object elements[] = ((IStructuredSelection)viewer.getSelection()).toArray();
 if(elements.length > 0) {
  IMemento selectionMem = memento.createChild(TAG_SELECTION);
  for (int i = 0; i < elements.length; i++) {
    ICElement e  = (ICElement)elements[i]; // ClassCastException !!!

It looks to me that a test with instanceof before casting would be required, 
although I do not catch everything what is made there and so, do not know what 
to do in the else branch.

Thanks in advance
Martin
Comment 1 Alain Magloire CLA 2003-04-25 17:15:07 EDT
You are right.
This is a bug, Will fix this.
Busy now will get back to you. Sorry for the delays.
Comment 2 Alain Magloire CLA 2003-04-26 20:19:44 EDT
Nice cath, martin.  It is fix in the cvs head.
Will close this PR once the patch is move in the cdt_1_1 branch.

Thanks
Comment 3 Alain Magloire CLA 2003-04-29 15:04:24 EDT
Fix in head and CDT_1_1

Pr Fixed

Thanks