[OpenJDK 2D-Dev] [9] RFR JDK-7064425: PageFormat Dialog has no owner window to reactivate
Prasanta Sadhukhan
prasanta.sadhukhan at oracle.com
Thu Sep 1 09:16:49 UTC 2016
Hi Phil,
Please find the modified webrev
http://cr.openjdk.java.net/~psadhukhan/7064425/webrev.02/
This takes care of removing DialogOwner attribute before printDialog
returns.
However, I could not use the same optimisation in WPrinterJob as mentioned
>>/WPrintDialog dialog = new WPrintDialog(//((owner instanceof
Frame)//? (Frame)owner : (Dialog)owner), this)
/
because it caused compilation failure saying
/
[no suitable constructor found for WPrintDialog((owner
ins[...]owner,WPrinterJob)//
// WPrintDialog dialog = new WPrintDialog(//
// ^//
// constructor WPrintDialog.WPrintDialog(Frame,PrinterJob) is not
applicable//
// (argument mismatch; bad type in conditional expression//
// Dialog cannot be converted to Frame)//
// constructor WPrintDialog.WPrintDialog(Dialog,PrinterJob) is not
applicable//
// (argument mismatch; bad type in conditional expression//
// Frame cannot be converted to Dialog)]//
/
I tried a sample program too to see if it's java issue and there also
the compilation fails
class TestA {
public TestA(Dialog temp) {}
public TestA(Frame temp) {}
}
public class TestB {
public static void main(String[] args) {
Window val = new Frame();
TestA test = new TestA((val instanceof Frame) ? (Frame)
val : (Dialog) val);
}
}
It seems compiler needs to determine what constructor to call. So both
operands of the conditional operator should be assignable to the type of
the parameter.
Regards
Prasanta
On 9/1/2016 12:07 AM, Phil Race wrote:
> 911 public boolean printDialog(final PrintRequestAttributeSet attributes)
> ...
> 956 attributes.add(new DialogOwner((Frame)w));
>
> So this now adds the DialogOwner to the attribute set passed by the application.
>
> This needs to be guaranteed to be removed again before the method returns otherwise
> apart from leaving that visible to the application, there is some risk that the
> frame will not be GC'd when it should have been.
>
> - Frame ownerFrame = (dlgOwner != null) ? dlgOwner.getOwner() : null;
> + Window ownerFrame = (dlgOwner != null) ? dlgOwner.getOwner() : null
> so maybe change the var name to just "owner" ?
> WPrintDialog dialog;
> 484 if (ownerFrame instanceof Frame) {
> 485 dialog = new WPrintDialog((Frame)ownerFrame, this);
> 486 } else {
> 487 dialog = new WPrintDialog((Dialog)ownerFrame, this);
> 488 } could (should?) be WPrintDialog dialog = new
> WPrintDialog(((owner instanceof Frame) ? (Frame)owner : (Dialog)owner), this)
>
> and so on for the other cases too .. it will save a lot
> of repetition for newPrintToFileErrorDialog(..)
>
> -phil.
>
> On 08/26/2016 01:05 AM, Prasanta Sadhukhan wrote:
>> Hi All,
>>
>> I have modified the webrev to take care of JDK-6948907
>> <https://bugs.openjdk.java.net/browse/JDK-6948907>:
>> sun.print.DialogOwner does not support Dialogs as DialogOwner
>> also.
>> http://cr.openjdk.java.net/~psadhukhan/7064425/webrev.01/
>>
>> Tested on windows and ubuntu.
>>
>> Regards
>> Prasanta
>> On 8/25/2016 4:10 PM, Prasanta Sadhukhan wrote:
>>> Hi All,
>>>
>>> Please review a fix for jdk9 for an issue where it is seen that
>>> PageDialog and PrintDialog is not associated with the owner Frame
>>> that spawns the dialog.
>>>
>>> Bug: https://bugs.openjdk.java.net/browse/JDK-7064425
>>> webrev: http://cr.openjdk.java.net/~psadhukhan/7064425/webrev.00/
>>>
>>> The issue was there we explicitly pass null as owner to
>>> ServiceDialog in pageDialog(attributes).
>>> Proposed fix is to get the owner window,
>>> if pageDialog is called before calling printDialog, the window will
>>> be a Frame else the owner window will be ServiceDialog
>>> and pass this owner window to ServiceDialog instead of null.
>>>
>>> For PrintDialog, the proposed fix is to set an attribute with
>>> DialogOwner so that ServiceUI dialog can parse that attribute and
>>> can use the owner window as parent of the dialaog,
>>>
>>> Regards
>>> Prasanta
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/2d-dev/attachments/20160901/0e7c9ab1/attachment.html>
More information about the 2d-dev
mailing list