#15694 closed defect (fixed)

wxAuiNotebookXmlHandler: attribute m_isInside not initialized

Reported by: R.U.10 Owned by:
Priority: normal Milestone:
Component: XRC Version: stable-latest
Keywords: wxAuiNotebookXmlHandler m_isInside Cc:
Blocked By: Blocking: #15686, #15686, #15686, #15686, #15686, #15686, #15686, #15686, #15686, #15686, #15686, #15686, #15686, #15686, #15686, #15686
Patch: yes

Description

The attribute m_isInside of the class wxAuiNotebookXmlHandler is not initialized. The uninitialized value is read to true in the method CanHandle which prevents the creation of the main notebook.

Attachments (1)

xh_auinotbk.cpp.patch download (382 bytes) - added by R.U.10 11 months ago.
Initialize m_isInside

Download all attachments as: .zip

Change History (17)

Changed 11 months ago by R.U.10

Initialize m_isInside

comment:1 Changed 11 months ago by R.U.10

  • Blocking

(In #15686) I brought all the expected corrections and improvements.
I created a "AUI XRC demo" dialog in the XRC sample which also exhibits the wxAuiNotebook (which allowed to discover the defect #15694).

Replying to vadz:

One question I have is about the use of "#ifdef __WXMSW__" in the code: why is it needed?

I don't know, it is borrowed as is from the code of wxToolBarXmlHandler...

comment:2 Changed 11 months ago by vadz

  • Blocking

(In #15686) Thanks for the update!

Looks good to me so I'm going to commit it to the trunk. In principle, this could be backported to 3.0 but I'd prefer to get some testing for it first. And if this goes to 3.0, version-script.in would need to be updated too (and the new header taken inside #if wxABI_VERSION >= 30100 check).

Thanks again!

comment:3 Changed 11 months ago by VZ

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

(In [75269]) Initialize wxAuiNotebookXmlHandler::m_isInside in ctor.

Closes #15694.

comment:4 Changed 11 months ago by VZ

  • Blocking

(In #15686) (In [75271]) Add XRC handler for wxAuiToolBar.

Also add the demonstration of AUI handlers (this one and the existing one for
wxAuiNotebook) to the xrc sample.

See #15686.

comment:5 Changed 11 months ago by R.U.10

  • Blocking

(In #15686) Replying to vadz:

if this goes to 3.0, version-script.in would need to be updated

Done

comment:6 Changed 11 months ago by R.U.10

  • Blocking

(In #15686) I'm the author of the XRC sample, the documentation and the final integration and 'WXification' of the code, but the originally author of wxAuiToolbarXmlHandler is one of my colleagues, I thus modified the name in the header.

comment:7 Changed 11 months ago by VZ

  • Blocking

(In #15686) (In [75286]) Correct the author of wxAuiToolBarXmlHandler.

See #15686.

comment:8 Changed 9 months ago by vadz

  • Blocking

(In #15686) Unfortunately this change broke DLL build under MSW:

   Creating library ..\..\lib\vc120_dll\wxmsw31ud_aui.lib and object ..\..\lib\vc120_dll\wxmsw31ud_aui.exp
auidll_xh_auitoolb.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: enum wxXmlNodeType __thiscall wxXmlNode::GetType(void)const " (__imp_?GetType@wxXmlNode@@QBE?AW4wxXmlNodeType@@XZ) referenced in function "public: virtual class wxObject * __thiscall wxAuiToolBarXmlHandler::DoCreateResource(void)" (?DoCreateResource@wxAuiToolBarXmlHandler@@UAEPAVwxObject@@XZ)
auidll_xh_auitoolb.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class wxString const & __thiscall wxXmlNode::GetName(void)const " (__imp_?GetName@wxXmlNode@@QBEABVwxString@@XZ) referenced in function "public: virtual class wxObject * __thiscall wxAuiToolBarXmlHandler::DoCreateResource(void)" (?DoCreateResource@wxAuiToolBarXmlHandler@@UAEPAVwxObject@@XZ)
auidll_xh_auitoolb.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class wxXmlNode * __thiscall wxXmlNode::GetNext(void)const " (__imp_?GetNext@wxXmlNode@@QBEPAV1@XZ) referenced in function "public: virtual class wxObject * __thiscall wxAuiToolBarXmlHandler::DoCreateResource(void)" (?DoCreateResource@wxAuiToolBarXmlHandler@@UAEPAVwxObject@@XZ)
auidll_xh_auitoolb.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class wxXmlNode * __thiscall wxXmlNode::GetChildren(void)const " (__imp_?GetChildren@wxXmlNode@@QBEPAV1@XZ) referenced in function "public: virtual class wxObject * __thiscall wxAuiToolBarXmlHandler::DoCreateResource(void)" (?DoCreateResource@wxAuiToolBarXmlHandler@@UAEPAVwxObject@@XZ)
..\..\lib\vc120_dll\wxmsw310ud_aui_vc_custom.dll : fatal error LNK1120: 4 unresolved externals

The reason is that we can't use wxXmlNode directly outside of the XRC library but these 4 methods are used directly in src/xrc/xh_auitoolb.cpp. If we really can't do without them, we must virtualize them via wxXmlResourceHandlerImpl, i.e. add GetNodeType() and so on.

But we must fix the build somehow...

comment:9 Changed 9 months ago by R.U.10

  • Blocking

(In #15686) It seems that I forgot to add the modifications of multilib.bkl in the patch.

comment:10 Changed 9 months ago by vadz

  • Blocking

(In #15686) I'd strongly prefer to avoid adding this dependency, it's perfectly possible (and, indeed, much more common) to use AUI without XRC. And we did all this XRC virtualization thing exactly in order to allow having XRC handlers in the library without linking with XRC library itself.

comment:11 Changed 9 months ago by R.U.10

  • Blocking

(In #15686) I'm in trouble with the return value of GetNodeType if the node param is NULL.
I would like to do something like that:

In file xmlres.h

enum  WXDLLIMPEXP_FWD_XML wxXmlNodeType;

class WXDLLIMPEXP_XRC wxXmlResourceHandlerImpl : public wxXmlResourceHandlerImplBase
{
public:
    wxXmlNodeType GetNodeType(const wxXmlNode *node) const
    {
        if (node == NULL) return 0;
        return node->GetType();
    }    
};

But there is no enum value for an unknown wxXmlNodeType.

Do you prefer to add an enum value wxXML_UNKNOWN_NODE = 0, in xml.h ?
Or to replace the return type of wxXmlResourceHandlerImpl::GetNodeType by size_t ?
Or perhaps do you have an other idea (no check of the node pointer value...) ?

comment:12 Changed 9 months ago by vadz

  • Blocking

(In #15686) Notice that you can't forward declare an enum. Of course, we could work around this (using an enum doesn't require linking with anything), but perhaps it would be better to not provide GetNodeType() but just IsXmlNode()? Looking at the existing handlers, no elements of this enum other than wxXML_ELEMENT_NODE are used currently, so it seems to be the only information that we need.

Thanks for looking at this!

comment:13 Changed 9 months ago by R.U.10

  • Blocking

(In #15686) Thank you for your proposals!

But I probably missed something because related to my implementation (see wxAuiToolbarXmlHandler_linking_issue.patch) the linking errors are just put back a little further:

   Creating library ..\..\lib\vc_dll\wxmsw31ud_aui.lib and object ..\..\lib\vc_dll\wxmsw31ud_aui.exp
auidll_xh_auitoolb.obj : error LNK2019: unresolved external "__declspec(dllimport) protected: class wxString const & __thiscall wxXmlResourceHandler::GetNodeName(class wxXmlNode const *)const " (__imp_?GetNodeName@wxXmlResourceHandler@@IBEABVwxString@@PBVwxXmlNode@@@Z) referenced in function "public: virtual class wxObject * __thiscall wxAuiToolBarXmlHandler::DoCreateResource(void)" (?DoCreateResource@wxAuiToolBarXmlHandler@@UAEPAVwxObject@@XZ)
auidll_xh_auitoolb.obj : error LNK2019: unresolved external "__declspec(dllimport) protected: bool __thiscall wxXmlResourceHandler::IsElementNode(class wxXmlNode const *)const " (__imp_?IsElementNode@wxXmlResourceHandler@@IBE_NPBVwxXmlNode@@@Z) referenced in function "public: virtual class wxObject * __thiscall wxAuiToolBarXmlHandler::DoCreateResource(void)" (?DoCreateResource@wxAuiToolBarXmlHandler@@UAEPAVwxObject@@XZ)
auidll_xh_auitoolb.obj : error LNK2019: unresolved external "__declspec(dllimport) protected: class wxXmlNode * __thiscall wxXmlResourceHandler::GetNodeNext(class wxXmlNode const *)const " (__imp_?GetNodeNext@wxXmlResourceHandler@@IBEPAVwxXmlNode@@PBV2@@Z) referenced in function "public: virtual class wxObject * __thiscall wxAuiToolBarXmlHandler::DoCreateResource(void)" (?DoCreateResource@wxAuiToolBarXmlHandler@@UAEPAVwxObject@@XZ)
auidll_xh_auitoolb.obj : error LNK2019: unresolved external "__declspec(dllimport) protected: class wxXmlNode * __thiscall wxXmlResourceHandler::GetNodeChildren(class wxXmlNode const *)const " (__imp_?GetNodeChildren@wxXmlResourceHandler@@IBEPAVwxXmlNode@@PBV2@@Z) referenced in function "public: virtual class wxObject * __thiscall wxAuiToolBarXmlHandler::DoCreateResource(void)" (?DoCreateResource@wxAuiToolBarXmlHandler@@UAEPAVwxObject@@XZ)
..\..\lib\vc_dll\wxmsw310ud_aui_vc_custom.dll : fatal error LNK1120: 4 unresolved externals

comment:14 Changed 9 months ago by vadz

  • Blocking

(In #15686) I don't understand this, everything looks fine to me. Sorry for a stupid question, but did you rebuild the core library? It should really have these symbols now...

comment:15 Changed 9 months ago by R.U.10

  • Blocking

(In #15686) You are right, just a clean up and it compiles...

So the latest submitted patch should correct the linking issues you reported (I also added the doc).

Regards,
KH

comment:16 Changed 9 months ago by VZ

  • Blocking

(In #15686) (In [75734]) Virtualize wxXmlNode methods used by wxAuiToolBarXmlHandler.

This fixes the DLL build of aui library as it can now be linked without
leaving any unresolved dependencies to the code in xml library (where
wxXmlNode is implemented).

Closes #15686.

Note: See TracTickets for help on using tickets.