Problems with KHTMView (and KHTMLPart) constructors

Eeli Kaikkonen eekaikko at mail.student.oulu.fi
Mon Dec 17 10:09:27 GMT 2007


On Mon, 17 Dec 2007, Germain Garand wrote:
> We are not going to change the API at this point, but please check if the
> attached patch may address your concerns.

Unfortunately it crashes. Here is the debug output:

(BibleTime 1.7.alpha) Debug: bibletime(18293)/khtml KHTMLGlobal::ref:
Creating KHTMLGlobal instance
(BibleTime 1.7.alpha) Debug: bibletime(18293)/khtml KHTMLGlobal::ref:
s_refcnt= 1
(BibleTime 1.7.alpha) Debug: bibletime(18293)/khtml KHTMLGlobal::ref:
s_refcnt= 1
(BibleTime 1.7.alpha) Debug: bibletime(18293)/khtml KHTMLGlobal::deref:
s_refcnt= 0
(BibleTime 1.7.alpha) Debug: bibletime(18293)/khtml
KHTMLGlobal::~KHTMLGlobal: 0x8369340
(BibleTime 1.7.alpha) Debug: bibletime(18293)/khtml
KHTMLGlobal::finalCheck: s_refcnt= 0
(BibleTime 1.7.alpha) Debug: bibletime(18293) KHTMLGlobal::registerPart:
KHTMLPart(0x849c950)
(BibleTime 1.7.alpha) Debug: bibletime(18293)/khtml KHTMLGlobal::ref:
Creating KHTMLGlobal instance
(BibleTime 1.7.alpha) Debug: bibletime(18293)/khtml KHTMLGlobal::ref:
s_refcnt= 1
(BibleTime 1.7.alpha) Debug: bibletime(18293)/khtml KHTMLGlobal::ref:
s_refcnt= 1
bibletime: /work/src/kde4/kdelibs/khtml/khtmlview.cpp:528: void
KHTMLView::setPart(KHTMLPart*): Assertion `part && !m_part' failed.

And the relevent part of the backtrace:

#9  0xb65aad2d in KHTMLView::setPart (this=0x6, part=0x849c950)
    at /work/src/kde4/kdelibs/khtml/khtmlview.cpp:528
#10 0xb65f1a8e in KHTMLPart (this=0x849c950, __vtt_parm=0x817b744,
    view=0x81df1f8, parent=0x85d0aa8, prof=KHTMLPart::DefaultGUI)
    at /work/src/kde4/kdelibs/khtml/khtml_part.cpp:229


This is our code where this happens:

CHTMLReadDisplay::CHTMLReadDisplay(CReadWindow* readWindow, QWidget*
parentWidget)
	: KHTMLPart(m_view = new CHTMLReadDisplayView(
			this, parentWidget ? parentWidget : readWindow),
readWindow ? readWindow : parentWidget),

(Our class is used in different situations, therefore the hairy code.
It's easy to see why my first thought when seeing this code was "this
will be break things some day".)


> It adds:
> 1) the possibility of constructing a KHTMLView beforehand with a 0L part
>    pointer. That pointer will be updated by the KHTMLPart constructor.
> 2) some documentation describing 1) and also view creation from
>    part constructor initialization list
> 3) a unit test asserting 1)

Thank you very much! This is what I wanted but more than I expected. The
new constructor and the documentation looks great. I will probably test
our code with the new method later, after we get the current one
working.

One note about the unit test: it doesn't test the init list
constructing. That should be added, I think. Maybe that would have
cought also the bug I now found...


  Yours,
	Eeli Kaikkonen (Mr.), Oulu, Finland
	e-mail: eekaikko at mailx.studentx.oulux.fix (with no x)




More information about the kfm-devel mailing list