Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » TabCtrl » Question and problems around TabCtrl
Question and problems around TabCtrl [message #27546] Thu, 22 July 2010 22:12 Go to next message
mubeta is currently offline  mubeta
Messages: 61
Registered: October 2006
Member
Hi all,
Windows XP 32 + SP3; MSC9; U++ 2467.

Using TabCtrl with an array of same layout I have this problem:

//main.h

Array<WithlDevice<ParentCtrl> > layer;
TabCtrl                tab;

//main.cpp

void App::DoSomething_1(void)
{
  for(int i=0; i<5; i++) {
    CtrlLayout(layer.At(i));
    tab.Add(layer.At(i).SizePos(), AppImg::...(), t_("...")); 
  }
}

void App::DoSomething_2(void)
{
  for(int z = tab.GetCount() - 1; z > 0; z--) tab.Remove(z);
  tab.ClearFrames();
  tab.GetItem(0).SetImage(Nuller()).Text("");
  layer.Clear();
}


First step:
Calling DoSomething_1() the application will add 5 tabs and all work fine.

Second step:
Calling DoSomething_2() the application will remove 4 of 5 tabs. (Using Reset() result in a system crash, the system crash also if trying to remove alla the 5 tabs).

Third step:
Calling DoSomething_1() again result in a system crash at the line: tab.Add(....);

Questions:
1) It is correct that tab.Reset() result in a system crash? I must leave one tab ?
2) Adding new tabs after remove is not possible?

3) Can be windows problem? or compiler?

Note that the posted code it's only an abstract.
Thanks a lot.
Re: Question and problems around TabCtrl [message #27559 is a reply to message #27546] Fri, 23 July 2010 11:24 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11844
Registered: November 2005
Ultimate Member
mubeta wrote on Thu, 22 July 2010 16:12

Hi all,
Windows XP 32 + SP3; MSC9; U++ 2467.

Using TabCtrl with an array of same layout I have this problem:

//main.h

Array<WithlDevice<ParentCtrl> > layer;
TabCtrl                tab;

//main.cpp

void App::DoSomething_1(void)
{
  for(int i=0; i<5; i++) {
    CtrlLayout(layer.At(i));
    tab.Add(layer.At(i).SizePos(), AppImg::...(), t_("...")); 
  }
}

void App::DoSomething_2(void)
{
  for(int z = tab.GetCount() - 1; z > 0; z--) tab.Remove(z);
  tab.ClearFrames();
  tab.GetItem(0).SetImage(Nuller()).Text("");
  layer.Clear();
}


First step:
Calling DoSomething_1() the application will add 5 tabs and all work fine.

Second step:
Calling DoSomething_2() the application will remove 4 of 5 tabs. (Using Reset() result in a system crash, the system crash also if trying to remove alla the 5 tabs).

Third step:
Calling DoSomething_1() again result in a system crash at the line: tab.Add(....);

Questions:
1) It is correct that tab.Reset() result in a system crash? I must leave one tab ?
2) Adding new tabs after remove is not possible?

3) Can be windows problem? or compiler?

Note that the posted code it's only an abstract.
Thanks a lot.


I might be wrong, but it looks like in DoSomething_2 you do layer.Clear(); while layer[0] is still part of TabCtrl. I believe this is the cause of troubles.
Re: Question and problems around TabCtrl [message #27564 is a reply to message #27559] Fri, 23 July 2010 11:54 Go to previous message
mubeta is currently offline  mubeta
Messages: 61
Registered: October 2006
Member
I found the cause, but I need a long time for follow all the codes:

So:
After add an tab, I also set a callback to WhenSet:

tab.WhenSet << THISBACK(foo);

foo get information from tab, so, when tab.Reset() is destroing the last one, (tab.Reset() method call again WhenSet() before to return), I get the crash.

WhenSet() is called again, at the second time adding loop, in this case it's really dangerous, because all the need vars are not ready.

So, in fact:
First step: adding tabs all is ok, because WhenSet is empty.
Second step: assign a callback to WhenSet.
Third step: resetting the tab result in a crash because Reset() also call WhenSet(), and in MY CASE is not good.
Third step: adding new tabs result in a crash becase WhenSet is assigned but my vars are not ready.

So, now the problem is: how to remove the WhenSet callback??
tab.WhenSet << 0; (compiler error)
tab.WhneSet = 0; (compiler error)
tab.WhenSet << CNULL; (compiler error)
tab.WhenSet << Callback::Empty(); (ok for compiler, but nothing change in the application. the callback in fact is not cleared).

uff.

I only need to be able to remove the WhenSet callback some times.
Previous Topic: How to change tabctrl background color ?
Next Topic: how to tell which tab is which
Goto Forum:
  


Current Time: Thu Apr 25 14:10:17 CEST 2019

Total time taken to generate the page: 0.01051 seconds