Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 346314

Summary: Printer.checkNull destructively modifies the user's PrinterData
Product: [Eclipse Project] Platform Reporter: Carolyn MacLeod <carolynmacleod4>
Component: SWTAssignee: Carolyn MacLeod <carolynmacleod4>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: gheorghe, Silenio_Quarti
Version: 3.7   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug

Description Carolyn MacLeod CLA 2011-05-18 14:13:08 EDT
In Printer.checkNull(data) the 2 lines:
		data.driver = defaultPrinter.driver;
		data.name = defaultPrinter.name;		
destructively modify the PrinterData that is passed in.
This should not happen.
The only way to avoid this is to have a copy/clone method in PrinterData, and keep a copy of the data that is passed in to the Printer constructor.
Comment 1 Carolyn MacLeod CLA 2011-05-18 14:30:08 EDT
See also bug 297957, which requests a public copy method.
(But not a "clone" method - see bug 4740).
See also bug 315932, for more background, and a case in StyledText that was failing because Printer does not keep a copy of the user's PrinterData.
All Printer/PrintDialog javadoc should be reviewed and fixed up if necessary, to explicitly state whether a copy of the PrinterData is used or not.
Comment 2 Lars Vogel CLA 2019-11-14 02:19:09 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

If the bug is still relevant, please remove the "stalebug" whiteboard tag.