Kirix Support Forums

Bug - Print() function does not work

Please post all general questions, comments, bug reports, and any other wxWebConnect feedback here.

Bug - Print() function does not work

Postby Doc on Thu Feb 03, 2011 11:38 am

Hi,
The basic Print function in 1.1 appears to be broken. I tried compiling it and printing the sample app, but nothing happens.

Running the debugger, I found that the line in wxWebControl::Print() that says:
Code: Select all
   
   ns_smartptr<nsIPrintSettings> settings19 = m_ptrs->m_print_settings;
    if (settings19)
    {

was always returning settings19==NULL - so the print would not occur. Investigating further it looks like the actual problem is with the definition of m_print_settings. In the EmbeddingPtrs structure, m_print_settings is defined as a nsISupports when it should be a nsIPrintSettings. The corrected code (which works) is:
Code: Select all
struct EmbeddingPtrs
{
    ns_smartptr<nsIWebBrowser> m_web_browser;
    ns_smartptr<nsIWebBrowserFind> m_web_browser_find;
    ns_smartptr<nsIBaseWindow> m_base_window;
    ns_smartptr<nsIWebNavigation> m_web_navigation;
    ns_smartptr<nsIDOMEventTarget> m_event_target;
    ns_smartptr<nsIClipboardCommands> m_clipboard_commands;
   
    // ns_smartptr<nsISupports> m_print_settings; // <== Seems to be the wrong type
    ns_smartptr<nsIPrintSettings> m_print_settings; // This is the right PrintSettings type
};

Hopefully you can update this in the next release. Also, as wxWidgets is at version 2.9 now, some of the makefiles and project libraries/includes need to be updated.

Thanks,
Brad
Doc
Registered User
 
Posts: 5
Joined: Sun Oct 14, 2007 2:58 am

Re: Bug - Print() function does not work

Postby Doc on Thu Feb 03, 2011 1:31 pm

Well - apparently the above code still has a problem. While it now executes fine and prints in silent mode, when I attempt to print in non-silent mode I get a heap error as it tries to write the print settings. both in the TestApp and in my own app.

I don't know quite enough about the interface to figure this out - so any advice on getting the TestApp to print properly would be appreciated. I'm compiling under wxWidgets 2.9, MSW, with Unicode debug mode.

Brad
Doc
Registered User
 
Posts: 5
Joined: Sun Oct 14, 2007 2:58 am

Re: Bug - Print() function does not work

Postby jonmmorgan on Fri Feb 04, 2011 7:35 am

wxWidgets 2.9 has been released, but it is still a development version. While it might be nice if it supported it (and I know people who are using wxWebConnect with wx 2.9), I don't think there is any obligation to support it, and it definitely shouldn't be updated in a way that breaks wx 2.8 support.
jonmmorgan
Registered User
 
Posts: 94
Joined: Fri May 14, 2010 9:48 am

Re: Bug - Print() function does not work

Postby jonmmorgan on Fri Feb 04, 2011 8:28 am

Good catch on the nsIPrintSettings interface in the embedding pointers. I'm fairly sure that you are right and your suggested solution is correct.

However, as to the remaining problem, I think it is because wxWebConnect's nsIPrintSettings comes from XULRunner 1.9.1 (UUID 5af07661-6477-4235-8814-4a45215855b8). The version of nsIPrintSettings from XULRunner 1.9.2 should be used instead (UUID 343700dd-078b-42b6-a809-b9c1d7e951d0). Using the wrong interface version and thus the wrong UUID will cause the cast to nsIPrintSettings to fail, and if this is not properly checked it will probably lead to a crash.

The process for fixing it is to:
1. Replace the definition of nsIPrintSettings in nsall.idl with the one from the XULRunner 1.9.2 SDK.
2. Regenerate nsall.h.
3. Recompile.

In fact, I just tried this and it worked with my app, though there are quirks that mean I'm not about to rush out and add print support (for example, it includes the URL in the header, which may be fine for Firefox, but is not fine for my app where I use a custom protocol handler and the URLs used internally are never entered by users - and nor do they need to be).

I have pushed the changes to my private repository - you might want to have a look at the commit and maybe apply the change to your version of wxWebConnect (see https://github.com/jonmmorgan/wxwebconn ... c229777269).
jonmmorgan
Registered User
 
Posts: 94
Joined: Fri May 14, 2010 9:48 am

Return to wxWebConnect Questions, Thoughts & Feedback