Problem with active object - CTimer - SetActive()

Login to reply to this topic.
Thu, 2007-09-20 13:45
Joined: 2007-04-02
Forum posts: 4

Hi all,

I want to make this timer work but it crashes on SetActive() command.

Class symbian_timer_helper is derived from : public CTimer. It crashes but does not even run RunL() command of CTimer! It does not even start the timer if I remove SetActive().

Here is the code:

void symbian_timer_helper::base_constructL()
{
CTimer::ConstructL() ;
}

symbian_timer_helper * symbian_timer_helper::constructL()
{
symbian_timer_helper * self = new (ELeave) symbian_timer_helper();
CleanupStack::PushL(self);
self->base_constructL() ;
CleanupStack::Pop();
CActiveScheduler::Add(self) ; // did I start the active scheduler with this?
return self;
}

After this start is called:

void symbian_timer_helper::start(int timeout_value,
timer_expiry_handler & i_timeout_handler)
{
timeout_handler = (& i_timeout_handler) ;
TTimeIntervalMicroSeconds32 timeout_interval((TInt)timeout_value) ;

After(timeout_interval) ;

SetActive() ; // mega-crash but why???
}

Where ussualy problems are with SetActive() command?
Just to say I'm a beginner in Symbian, btw.

Thanx very much in advance !!


Thu, 2007-09-20 14:55
Forum Nokia Champion
Joined: 2004-05-26
Forum posts: 732
Re: Problem with active object - CTimer - SetActive()

I think you should understand the basics of the Active Shecduler (AS) first. Hope there are plenty of articles available from NewLC tutorials and Forum Nokia Wiki, just do a search. Before calling SetActve you should call an asynchronous function where in which you should pass the iStatus (which is an object of CActive a TRequestStust type).

The next thing is you've some misconception on CounstructL(). A part of code in ConstructL() should be moved to the NewL()/NewLC() function. AFAIK your ConstructL() can't return any value, you can call any of the leaving functions inside it. Search for Two-Phase construction and CleanupStack. Another observation is that you've not followed the Symbian naming conventions properly.

I would recommend you to check any of the implementation of CTimer with SDK Help to get know more about it.


Thu, 2007-09-20 17:55
Joined: 2006-05-09
Forum posts: 78
Re: Problem with active object - CTimer - SetActive()

Read the documentation for CTimer, it says you have to provide an implementation of RunL(), where is it?

Sat, 2007-09-22 05:30
Joined: 2006-10-07
Forum posts: 131
Re: Problem with active object - CTimer - SetActive()

 After(timeout_interval) ;

SetActive() ; // mega-crash but why???

I bet it is a E32USER-CBase 42 panic. SetActive() was already called in CTimer::After(...).

Tue, 2007-09-25 10:45
Joined: 2007-04-02
Forum posts: 4
Re: Problem with active object - CTimer - SetActive()

Thanx sysctl-forum

i have removed SetActive() and now everything works fine!

bye

  • Login to reply to this topic.