Revert to using wxBaseObjectArray for wxAuiToolBarItemArray
This partially undoes the changes of bc23b1f4f0 (Use wxBaseArray instead
of object array for wxAuiToolBarItemArray, 2023-04-11) as they broke the
existing code using wxAuiToolBar because the pointers to the tools were
not stable any more.
At least avoid the use of the ugly -WX_DECLARE_USER_EXPORTED_OBJARRAY()
macro by just using wxBaseObjectArray<> directly, which is simpler now,
after the change in the parent commit.
Add a trivial test checking that pointers to wxAuiToolBar tools remain
stable when more tools are added.
Closes #23514.
This commit is contained in:
parent
91ded239e9
commit
50dcf06bff
2 changed files with 15 additions and 1 deletions
|
|
@ -254,7 +254,7 @@ private:
|
|||
int m_alignment; // sizer alignment flag, defaults to wxCENTER, may be wxEXPAND or any other
|
||||
};
|
||||
|
||||
using wxAuiToolBarItemArray = wxBaseArray<wxAuiToolBarItem>;
|
||||
using wxAuiToolBarItemArray = wxBaseObjectArray<wxAuiToolBarItem>;
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,10 +21,13 @@
|
|||
|
||||
#include "wx/panel.h"
|
||||
|
||||
#include "wx/aui/auibar.h"
|
||||
#include "wx/aui/auibook.h"
|
||||
|
||||
#include "asserthelper.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test fixtures
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
@ -165,4 +168,15 @@ TEST_CASE_METHOD(AuiNotebookTestCase, "wxAuiNotebook::FindPage", "[aui]")
|
|||
CHECK( nb->FindPage(p3) == wxNOT_FOUND );
|
||||
}
|
||||
|
||||
TEST_CASE("wxAuiToolBar::Items", "[aui][toolbar]")
|
||||
{
|
||||
std::unique_ptr<wxAuiToolBar> tbar{new wxAuiToolBar(wxTheApp->GetTopWindow())};
|
||||
|
||||
// Check that adding more toolbar elements doesn't invalidate the existing
|
||||
// pointers.
|
||||
auto first = tbar->AddLabel(wxID_ANY, "first");
|
||||
tbar->AddLabel(wxID_ANY, "second");
|
||||
CHECK( first->GetLabel() == "first" );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue