Discussion:
wxHtmlWindow parsing error
Hugo Benicio
2014-01-27 17:36:42 UTC
Permalink
Hi guys.
I'm trying to port my application from wxWidgets 2.8 to 3.0.0
I did all major changes needed in my code, but there is an issue
with wxHtmlWindow here that gives me no option but to ask for help here at
wxWidgets list.
I'm trying to load a html with it. It worked just fine with 2.8, but 3.0.0
gives me some runtime assertation errors during parsing.

Here is my code:

wxHtmlWindow *about = new wxHtmlWindow(this, -1, wxDefaultPosition,
wxSize(390,270));
about->SetRelatedFrame(dialog->frame, "SIGA");
abou ->SetRelatedStatusBar(0);
wxFileName exeFileName(wxStandardPaths::Get().GetExecutablePath());
wxString aboutFilePath = exeFileName.GetPathWithSep() + wxT("about.htm");
about->LoadFile(wxFileName(aboutFilePath));

And the html goes attached.

What I realized from the callstack is that wxHtmlWindow is parsing the
title element from html, then trying to set the title with
wxHtmlWindow::OnSetTitle, which calls wxString::Printf that fails for some
strange reason. I can send you the complete callstack is needed.

Please, can someone help me? All my efforts were worthless...

Thanks in advance, Hugo BenĂ­cio.

PS.: I tried a Unicode version of the html file... didn't work.
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Vadim Zeitlin
2014-01-27 18:29:13 UTC
Permalink
On Mon, 27 Jan 2014 15:36:42 -0200 Hugo Benicio wrote:

HB> I'm trying to load a html with it. It worked just fine with 2.8, but 3.0.0
HB> gives me some runtime assertation errors during parsing.

This is really not precise enough. Which runtime assertion (hint: if
you're under Windows, you can press Ctrl+C in the message box to copy its
contents to the clipboard)? Where does it happen? What is the stack trace?

HB> Here is my code:
HB>
HB> wxHtmlWindow *about = new wxHtmlWindow(this, -1, wxDefaultPosition,
HB> wxSize(390,270));
HB> about->SetRelatedFrame(dialog->frame, "SIGA");
HB> abou ->SetRelatedStatusBar(0);
HB> wxFileName exeFileName(wxStandardPaths::Get().GetExecutablePath());
HB> wxString aboutFilePath = exeFileName.GetPathWithSep() + wxT("about.htm");
HB> about->LoadFile(wxFileName(aboutFilePath));

There is nothing wrong here.

HB> And the html goes attached.

This HTML works just fine in samples/html/about if you replace the
about.htm file included in the sample with it. Please try it with your
build of wxWidgets. If it doesn't work, please let us know which platform
do you use and how did you build wxWidgets, i.e. any non-default build
options you used.

HB> What I realized from the callstack is that wxHtmlWindow is parsing the
HB> title element from html, then trying to set the title with
HB> wxHtmlWindow::OnSetTitle, which calls wxString::Printf that fails for some
HB> strange reason. I can send you the complete callstack is needed.

This is always useful. Knowing the values of the parameters passed to
Printf() (which you can check under debugger if they're not included in the
stack) could be useful too.

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Hugo Benicio
2014-01-27 20:08:57 UTC
Permalink
The assertation and the stack trace that I get is the following (screenshot
attached. Sorry, I couldn't copy/paste this window).
It' happens on about->LoadFile(wxFileName(aboutFilePath)); when trying to
parse it.

I also forgot to say that I'm on wxMSW (Windows 7 32bits), Unicode, Debug
build, using wx as DLL.
Tomorrow I'll try to compile and use the sample app with my build and html.

Thanks for your attention.
Post by Vadim Zeitlin
HB> I'm trying to load a html with it. It worked just fine with 2.8, but 3.0.0
HB> gives me some runtime assertation errors during parsing.
This is really not precise enough. Which runtime assertion (hint: if
you're under Windows, you can press Ctrl+C in the message box to copy its
contents to the clipboard)? Where does it happen? What is the stack trace?
HB>
HB> wxHtmlWindow *about = new wxHtmlWindow(this, -1, wxDefaultPosition,
HB> wxSize(390,270));
HB> about->SetRelatedFrame(dialog->frame, "SIGA");
HB> abou ->SetRelatedStatusBar(0);
HB> wxFileName exeFileName(wxStandardPaths::Get().GetExecutablePath());
HB> wxString aboutFilePath = exeFileName.GetPathWithSep() +
wxT("about.htm");
HB> about->LoadFile(wxFileName(aboutFilePath));
There is nothing wrong here.
HB> And the html goes attached.
This HTML works just fine in samples/html/about if you replace the
about.htm file included in the sample with it. Please try it with your
build of wxWidgets. If it doesn't work, please let us know which platform
do you use and how did you build wxWidgets, i.e. any non-default build
options you used.
HB> What I realized from the callstack is that wxHtmlWindow is parsing the
HB> title element from html, then trying to set the title with
HB> wxHtmlWindow::OnSetTitle, which calls wxString::Printf that fails for some
HB> strange reason. I can send you the complete callstack is needed.
This is always useful. Knowing the values of the parameters passed to
Printf() (which you can check under debugger if they're not included in the
stack) could be useful too.
Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Vadim Zeitlin
2014-01-28 02:06:18 UTC
Permalink
On Mon, 27 Jan 2014 18:08:57 -0200 Hugo Benicio wrote:

HB> The assertation and the stack trace that I get is the following (screenshot
HB> attached. Sorry, I couldn't copy/paste this window).
HB> It' happens on about->LoadFile(wxFileName(aboutFilePath)); when trying to
HB> parse it.
HB>
HB> I also forgot to say that I'm on wxMSW (Windows 7 32bits), Unicode, Debug
HB> build, using wx as DLL.
HB> Tomorrow I'll try to compile and use the sample app with my build and html.

I think it will work for you because looking at the code it seems like you
passed a string with a wrong number of format specifiers to wxHtmlWindow::
SetRelatedFrame(). At least this is the only way I see for this to happen.

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Hugo Benicio
2014-01-28 13:19:00 UTC
Permalink
@Bob
Thanks for the tip, but I tried a minimal html if only html and body tags
and it didn't work also.

@Vadim
YES! You got it! =D
All this time the problem was the wxHtmlWindow::SetRelatedFrame() !
I just changed

about->SetRelatedFrame(dialog->frame, "SIGA");

to

about->SetRelatedFrame(dialog->frame, "%s");

And it worked!!! :D

So many thanks to you for noticing it. It was a legacy bug in my code that
was unnoticed by wx 2.8, but not in 3.0.0

Documentation about SetRelatedFrame says:
"*format* is the format of the frame title, e.g. "HtmlHelp : %s". It must
contain exactly one s."

So my question now is: Isn't it better for this function to check for this
"%s" format? With an assertation, maybe. As we noticed, if this "%s" format
were missing, LoadFile would crash with a not so intuitive error report.

Anyway, it works now! Thanks Bob and Vadim for your help! It saved me a lot
of time and headaches :)
Post by Vadim Zeitlin
HB> The assertation and the stack trace that I get is the following (screenshot
HB> attached. Sorry, I couldn't copy/paste this window).
HB> It' happens on about->LoadFile(wxFileName(aboutFilePath)); when trying to
HB> parse it.
HB>
HB> I also forgot to say that I'm on wxMSW (Windows 7 32bits), Unicode, Debug
HB> build, using wx as DLL.
HB> Tomorrow I'll try to compile and use the sample app with my build and html.
I think it will work for you because looking at the code it seems like you
SetRelatedFrame(). At least this is the only way I see for this to happen.
Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Hugo Benicio
2014-01-31 16:01:17 UTC
Permalink
May I open a ticket for it?
Or this improvement isn't really necessary/desirable?
Post by Hugo Benicio
@Bob
Thanks for the tip, but I tried a minimal html if only html and body tags
and it didn't work also.
@Vadim
YES! You got it! =D
All this time the problem was the wxHtmlWindow::SetRelatedFrame() !
I just changed
about->SetRelatedFrame(dialog->frame, "SIGA");
to
about->SetRelatedFrame(dialog->frame, "%s");
And it worked!!! :D
So many thanks to you for noticing it. It was a legacy bug in my code that
was unnoticed by wx 2.8, but not in 3.0.0
"*format* is the format of the frame title, e.g. "HtmlHelp : %s". It must
contain exactly one s."
So my question now is: Isn't it better for this function to check for this
"%s" format? With an assertation, maybe. As we noticed, if this "%s" format
were missing, LoadFile would crash with a not so intuitive error report.
Anyway, it works now! Thanks Bob and Vadim for your help! It saved me a
lot of time and headaches :)
Post by Vadim Zeitlin
HB> The assertation and the stack trace that I get is the following (screenshot
HB> attached. Sorry, I couldn't copy/paste this window).
HB> It' happens on about->LoadFile(wxFileName(aboutFilePath)); when trying to
HB> parse it.
HB>
HB> I also forgot to say that I'm on wxMSW (Windows 7 32bits), Unicode, Debug
HB> build, using wx as DLL.
HB> Tomorrow I'll try to compile and use the sample app with my build and html.
I think it will work for you because looking at the code it seems like you
SetRelatedFrame(). At least this is the only way I see for this to happen.
Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Vadim Zeitlin
2014-01-31 16:07:26 UTC
Permalink
On Fri, 31 Jan 2014 14:01:17 -0200 Hugo Benicio wrote:

HB> May I open a ticket for it?
HB> Or this improvement isn't really necessary/desirable?
...
HB> >> I think it will work for you because looking at the code it seems like
HB> >> you passed a string with a wrong number of format specifiers to
HB> >> wxHtmlWindow:: SetRelatedFrame(). At least this is the only way I
HB> >> see for this to happen.

There is no simple way to check for this, the best we can [easily] do is
to give you the same assert sooner, e.g. in wxHtmlWindow::SetRelatedFrame()
itself. I've committed this change in r75748 but I'm not so sure it's
really going to help to be honest -- you'd still have to actually look at
the sources to find out what's going on.

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Bob Paddock
2014-01-27 20:18:58 UTC
Permalink
Post by Hugo Benicio
Hi guys.
I'm trying to port my application from wxWidgets 2.8 to 3.0.0
I did all major changes needed in my code, but there is an issue with
wxHtmlWindow
Make sure you HTML is properly formed. I've run into issues where
wxHtmlWindow would not work
with badly formed HTML that web browsers where happy with (they should
not have been but there is so much bad HTML out there...).


Try running your HTML through HTML Tidy then see what happens:

http://tidy.sourceforge.net/
http://www.w3.org/People/Raggett/tidy/













here that gives me no option but to ask for help here at
Post by Hugo Benicio
wxWidgets list.
I'm trying to load a html with it. It worked just fine with 2.8, but 3.0.0
gives me some runtime assertation errors during parsing.
wxHtmlWindow *about = new wxHtmlWindow(this, -1, wxDefaultPosition,
wxSize(390,270));
about->SetRelatedFrame(dialog->frame, "SIGA");
abou ->SetRelatedStatusBar(0);
wxFileName exeFileName(wxStandardPaths::Get().GetExecutablePath());
wxString aboutFilePath = exeFileName.GetPathWithSep() + wxT("about.htm");
about->LoadFile(wxFileName(aboutFilePath));
And the html goes attached.
What I realized from the callstack is that wxHtmlWindow is parsing the title
element from html, then trying to set the title with
wxHtmlWindow::OnSetTitle, which calls wxString::Printf that fails for some
strange reason. I can send you the complete callstack is needed.
Please, can someone help me? All my efforts were worthless...
Thanks in advance, Hugo BenĂ­cio.
PS.: I tried a Unicode version of the html file... didn't work.
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
or visit http://groups.google.com/group/wx-users
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Loading...