×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    47

    RContactDatabase and RThread problems

    Hello, everybody.

    I have problems with RThread.

    I use next line to call function in separate thread:
    Code:
            TInt res = iHashingPHThread.Create(KPBHashingThread, PhoneBookChanged, KDefaultStackSize, NULL, (TAny*) this);
    
            if (res == KErrNone)
            {
                iHashingPHThread.Resume();
            }
    This is my function:
    Code:
    TInt CCommonStorage::PhoneBookChanged(TAny* pObj)
    {
    	LOGF(_L("+ CCommonStorage::PhoneBookChanged()"));
    
    	CTrapCleanup* cleanupStack = CTrapCleanup::New();
    	
    	const CContactIdArray *itemArray = storage->GetDataBase()->SortedItemsL(); // just return array with contacts
    
    	storage->GetABChecksum(itemArray);
    
    	delete cleanupStack;
    	cleanupStack = NULL;
    	    
    	return 0;
    }
    
    TBool CCommonStorage::GetABChecksum(const CContactIdArray *itemArray)
    {
    	for (int i = 0; i < count; ++i)
    	{
    		TContactItemId itemID = (*itemArray)[i];
    
    		CContactItem *item = NULL;
    		item = pDatabase->ReadMinimalContactL(itemID); // exception cbase66
    
    		// do smth
    	}
    
    	return ret;
    }
    Actually I cannot perform any operations with stack. Where is my mistake and what should I do to fix it?

    Thank you.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,672

    Re: RContactDatabase and RThread problems

    For the panic itself, the explanation is that instantiating CTrapCleanup does not start using it. You need a TRAP/D for that.
    Code:
    TInt CCommonStorage::PhoneBookChanged(TAny* pObj)
    {
        LOGF(_L("+ CCommonStorage::PhoneBookChanged()"));
    
        CTrapCleanup* cleanupStack = CTrapCleanup::New();
        TRAPD(err,
            const CContactIdArray *itemArray = storage->GetDataBase()->SortedItemsL(); // just return array with contacts
            storage->GetABChecksum(itemArray);
        );
    
        delete cleanupStack;
        cleanupStack = NULL;
    
        return 0;
    }
    could be a minimal fix for this panic.

    However note that it is absolutely not sure that a single contact database object could be shared between threads. My guess would be exactly that it can not be shared, and in this case you will need creating an other instance in the secondary thread.

  3. #3
    Registered User
    Join Date
    Nov 2011
    Posts
    47

    Re: RContactDatabase and RThread problems

    It helped. But now, when I' trying create new db I get CBase44 panic.

    Code:
    TBool CCommonStorage::GetABChecksum(const CContactIdArray *itemArray)
    {
    	CContactDatabase *DB = CContactDatabase::OpenL(); // panic
    	for (int i = 0; i < count; ++i)
    	{
    		TContactItemId itemID = (*itemArray)[i];
    
    		CContactItem *item = NULL;
    		item = DB->ReadMinimalContactL(itemID);
    
    		// do smth
    	}
    
    	return ret;
    }

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,672

    Re: RContactDatabase and RThread problems

    Consider reading the documentation of that message, E32USER-CBase 44. Similarly to the Cleanup Stack, that other thing is also has to be created manually for a secondary thread. After creation, use Install, one of its static methods.

  5. #5
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167

    Re: RContactDatabase and RThread problems

    Can you check the panic again, and write it exactly as it is shown ?

Similar Threads

  1. RThread Cloes problems
    By kunlamp in forum Symbian
    Replies: 2
    Last Post: 2009-11-27, 01:29
  2. RThread().Id() and RThread.Open() Problem
    By NevenS in forum Symbian
    Replies: 21
    Last Post: 2008-10-16, 17:05
  3. Replies: 1
    Last Post: 2008-04-30, 23:04
  4. RThread
    By 1xuname1x in forum Symbian
    Replies: 4
    Last Post: 2005-10-22, 20:34
  5. Replies: 1
    Last Post: 2004-01-02, 17:48

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×