Opened 5 years ago

Closed 5 years ago

#15334 closed defect (fixed)

Wrong selection in wxOSX wxNotebook after deleting a page

Reported by: vadz Owned by:
Priority: normal Milestone: 3.0.0
Component: wxOSX Version:
Keywords: notebook selection inconsistency Cc: csomor@…
Blocked By: Blocking:
Patch: no


We have a unit test failure currently:

Test name: NotebookTestCase::PageManagement
equality assertion failed
- Expected: 1
- Actual  : 2

and running the widgets sample, creating 3 pages on its notebook page, selecting the page 1 and removing the page 0 makes the selection indeed jump to the old page 2, i.e. another page. This is unexpected, it should really stay on the same page and the selection value should change.

I thought fixing this would be easy and tried

  • src/osx/notebook_osx.cpp

    diff --git a/src/osx/notebook_osx.cpp b/src/osx/notebook_osx.cpp
    index 90dc488..728d405 100644
    a b wxNotebookPage* wxNotebook::DoRemovePage(size_t nPage) 
    177177    MacSetupTabs();
    179     if (m_selection >= (int)GetPageCount())
    180         m_selection = GetPageCount() - 1;
     179    if ( m_selection >= (int)nPage )
     180        m_selection--;
    182182    if (m_selection >= 0)
    183183        m_pages[m_selection]->Show(true);

but while this does make the unit test pass, it breaks the behaviour in an even worse way: now after the same actions in the widgets sample, no page is shown at all.

I see that Show(true) actually has no effect because the page is already considered to be shown at wxWindow level, but this seems correct. What I don't understand is why is it in fact really hidden. Would you have any idea about this, Stefan?

It would be nice to fix this but if not, we need to at least document the discrepancy in behaviour and disable the failing test.

Change History (1)

comment:1 Changed 5 years ago by SC

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

(In [74535]) keeping selected page, fixes #15334

Note: See TracTickets for help on using tickets.