Kirix Support Forums

Bug with InsertPage() in conjunction with setActive=true

Please post all general questions, comments, bug reports, and any other wxAUI feedback here.

Bug with InsertPage() in conjunction with setActive=true

Postby jfrench on Mon Jan 08, 2007 10:42 am

Hi,

If say page 3 is active and you insert a page just before page 3 and pass in true to set it active, nothinf happens because of the guard in SetSelection() (the active index hasn't changed but the page has). I fixed this locally by adding a 'force' param to SetSelection() and defaulting it to false. Don't know if it's the best solution though.

Thatmay be my last bug for a while as my integration is nearing completion. Everything working very nicely.

Cheers,
James
jfrench
Registered User
 
Posts: 14
Joined: Mon Dec 18, 2006 6:58 am

Postby Ben on Mon Jan 08, 2007 12:38 pm

Hi James,

Thanks for pointing this out!

Best,
Ben
User avatar
Ben
Kirix Support Team
 
Posts: 522
Joined: Mon Dec 19, 2005 6:29 am

Postby jfrench on Mon Jan 15, 2007 7:02 pm

Hi Ben,

I've just fallen foul of that guard in SetSelection() again. I noticed a few time that the tabs we're sometimes unclickable after a reordering op, but I didn't pay it much heed as I was too busy with the basics. Now I'm finessing I noticed it again. The unclickability was due to the guard in SetSelection().

It really is dangerous using indices as guards in a reorderable environment...

My fix is simply to remove the guard (and get rid of my previous 'force' param).

I guess you could change the way the guard works though.

I really will try and get some patches together but I'm incredibly busy at the mo with deadlines looming etc.... As I'm sure you are :)

Cheers,
James
jfrench
Registered User
 
Posts: 14
Joined: Mon Dec 18, 2006 6:58 am

Re: Bug with InsertPage() in conjunction with setActive=true

Postby andrey_yazhuk on Tue Aug 07, 2007 4:05 pm

Hello,

I reported a similar bug on wxWidgets SourceForge bug tracker, but Julian Smart advised me to post it here as well.

https://sourceforge.net/tracker/index.p ... tid=109863

Calling wxAuiNotebook::RemovePage(index) and InsertPage(index) and then SetSelection(index) with the same index results in the wrong page being activated. Debugger shows that wxNotebook believes that the right page has already been selected and so SetSelection() call does not do anything. Clicking on the page that should have been selected by SetSelection() also has no effect – tabs do not switch at all, however after a few clicks on other pages the control returns back to normal operation.
It seems that the state of the notebook becomes inconsistent so all attempts to update the control are being ignored. Calling Refresh() or Update() do not change anything.
I found a workaround – before removing a page select some other page, in this case everything works fine.

Why this happens – after call to InsertPage() the active page points to the same window, the index of this window changes (increments), but m_curpage member is not updated. This result in inconsistent state = current tab control points to one, while m_currpage number – to the another. Possible solution is to updated m_currpage if needed.

Example :

size_t index = notebook->GetPageIndex(child_w);
notebook->RemovePage(index);

notebook->InsertPage(index, new_page, label);
new_page->Reparent(notebook);
notebook->SetSelection(index);
// at this point notebook indicates that page “index” is selected, however on screen
// page “index +1” appears to be active

Andrey
andrey_yazhuk
Registered User
 
Posts: 4
Joined: Tue Aug 07, 2007 4:01 pm

Re: Bug with InsertPage() in conjunction with setActive=true

Postby Julian Smart on Fri Aug 10, 2007 7:14 am

Hi Andrey,

I wonder if you could add your suggested m_curpage fix and let us know if it works? If it does I'll commit to wxWidgets so we can have it in 2.8.5.

Many thanks in advance.

Regards,

Julian

andrey_yazhuk wrote:Hello,

I reported a similar bug on wxWidgets SourceForge bug tracker, but Julian Smart advised me to post it here as well.

https://sourceforge.net/tracker/index.p ... tid=109863

Calling wxAuiNotebook::RemovePage(index) and InsertPage(index) and then SetSelection(index) with the same index results in the wrong page being activated. Debugger shows that wxNotebook believes that the right page has already been selected and so SetSelection() call does not do anything. Clicking on the page that should have been selected by SetSelection() also has no effect – tabs do not switch at all, however after a few clicks on other pages the control returns back to normal operation.
It seems that the state of the notebook becomes inconsistent so all attempts to update the control are being ignored. Calling Refresh() or Update() do not change anything.
I found a workaround – before removing a page select some other page, in this case everything works fine.

Why this happens – after call to InsertPage() the active page points to the same window, the index of this window changes (increments), but m_curpage member is not updated. This result in inconsistent state = current tab control points to one, while m_currpage number – to the another. Possible solution is to updated m_currpage if needed.

Example :

size_t index = notebook->GetPageIndex(child_w);
notebook->RemovePage(index);

notebook->InsertPage(index, new_page, label);
new_page->Reparent(notebook);
notebook->SetSelection(index);
// at this point notebook indicates that page “index” is selected, however on screen
// page “index +1” appears to be active

Andrey
Julian Smart
Registered User
 
Posts: 17
Joined: Sun Nov 05, 2006 4:45 pm

Return to wxAUI Questions, Thoughts & Feedback