Opened 7 years ago

Closed 7 years ago

#394 closed enhancement (fixed)

SimplePrint bug when loading the capabilities with XHR

Reported by: elemoine Owned by:
Priority: major Milestone: ux
Component: ux Version:
Keywords: Cc:
State: Commit

Description

When providing the PrintProvider with a URL instead of capabilities the SimplePrint generates an error. This can easily be reproduced with the SimplePrint example.

Here's what happens: initComponent -> printExtent.addPage -> printExtent.fitPage -> printPage.fit -> printProvider.scales.getAt(0) -> BUG! The scales store isn't loaded yet.

Attachments (1)

patch-394-A0.diff (1.2 KB) - added by elemoine 7 years ago.

Download all attachments as: .zip

Change History (4)

Changed 7 years ago by elemoine

comment:1 Changed 7 years ago by elemoine

  • State changed from None to Review

If we just move

this.printPage = printExtent.addPage();

from initComponent to initForm we get an error when running the SimplePrint example. The error occurs in the example code: printForm.printPage is undefined in the getRotation context function.

This is because the print extent box is now drawn before printPage is set in the SimplePrint instance.

Actually, we shoudn't attempt to draw the print extent box before the capabilities are loaded. This suggests also moving

this.mapPanel.initPlugin(this.printExtent);

from initComponent to initForm.

But, in initForm, if we call initPlugin before addPage we get the same error in the SimplePage example (printForm.printPage is undefined), again this is because the print extent box is drawn before printPage is set in the SimplePrint instance.

If we call addPage before initPlugin we get an error in addPage, because this.map isn't set (we set it in initPlugin).

Yes, a can of worms.

To solve the addPage/initPlugin issue, we can create a page ourselves, pass it to the PrintExtent, and let the PrintExtent do the addPage.

See patch-394-A0.diff. Tests still pass with this patch applied. Please review.

comment:2 Changed 7 years ago by ahocevar

  • State changed from Review to Commit

Thanks @elemoine for the hard work on this. The patch looks great. Please commit.

comment:3 Changed 7 years ago by elemoine

  • Resolution set to fixed
  • Status changed from new to closed

(In [2556]) SimplePrint bug when loading the capabilities with XHR, r=ahocevar (closes #394)

Note: See TracTickets for help on using tickets.