×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Super Contributor
    Join Date
    Jun 2004
    Location
    SymbianLand
    Posts
    763

    Unhappy RPointerArray::Count() does not change after calling RPointerArray::Remove() ?

    Hi,
    I have a piece of code, which is behaving very strangely.
    It's a RPointerArray which am iterating in a for loop and then deleting entries using the RPointerArray::Remove function.
    Now the problem is that, even after a few items are deleted the RPointerArray::Count() still not reflect the deleted entries!!
    I have got the code reviewed with others and they haven't noticed any issues with it.
    The only thing is that I am running this code within a thread.
    The same code snippet when added to HelloWorld example app, seems to work fine, but not within the thread.
    Any pointers to fixing this issue?
    Thanks in advance.

  2. #2
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,142

    Re: RPointerArray::Count() does not change after calling RPointerArray::Remove() ?

    never seen that happening, and indeed it should never happen, so I would suggest re-checking that it is indeed happening. anyway , from API docs, I see that there is function called Compress();, maybe you could see if it makes any difference for you.

  3. #3
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,567

    Re: RPointerArray::Count() does not change after calling RPointerArray::Remove() ?

    RPointerArray just works fine. If Count does not seem to update, that is an other object. Check your code for passing the RPointerArray object by value, especially the part when it is passed to the thread function. I assume you are describing a situation where the array is created and used in different threads.
    Side note: since RPointerArray uses a heap-based buffer, the threads should use a shared heap.

  4. #4
    Super Contributor
    Join Date
    Jun 2004
    Location
    SymbianLand
    Posts
    763

    Re: RPointerArray::Count() does not change after calling RPointerArray::Remove() ?

    Quote Originally Posted by symbianyucca View Post
    never seen that happening, and indeed it should never happen, so I would suggest re-checking that it is indeed happening. anyway , from API docs, I see that there is function called Compress();, maybe you could see if it makes any difference for you.
    Tried Compress(), but that also did not help.


    Quote Originally Posted by wizard_hu_ View Post
    RPointerArray just works fine. If Count does not seem to update, that is an other object. Check your code for passing the RPointerArray object by value, especially the part when it is passed to the thread function. I assume you are describing a situation where the array is created and used in different threads.
    This variable is created locally in a function, so it seems more strange than ever. It isn't being shared between threads. Also I am mostly removing the 0th item always, will that make any difference?

  5. #5
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,567

    Re: RPointerArray::Count() does not change after calling RPointerArray::Remove() ?

    Evil question: how do you check Count() exactly?
    Otherwise no, it does not matter which item you are removing, the internals of RPointerArray are really simple.

  6. #6
    Super Contributor
    Join Date
    Jun 2004
    Location
    SymbianLand
    Posts
    763

    Re: RPointerArray::Count() does not change after calling RPointerArray::Remove() ?

    Quote Originally Posted by wizard_hu_ View Post
    Evil question: how do you check Count() exactly?
    By calling RPointerArray::Count() function.

  7. #7
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    3,956

    Re: RPointerArray::Count() does not change after calling RPointerArray::Remove() ?

    can you paste here the full function definition where this operation is taking place.

  8. #8
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,567

    Re: RPointerArray::Count() does not change after calling RPointerArray::Remove() ?

    I meant how you (as a person) get the value. Store it into a dummy variable and check it in the debugger? Display it on the screen (how? passing it to the primary thread? or via Open C printf?)? Logging it into a file?

Similar Threads

  1. Remove a specific element from a RPointerArray
    By ehsanTC in forum Symbian C++
    Replies: 5
    Last Post: 2012-02-04, 19:29
  2. App crash on calling of Count() of RPointerArray???
    By chandantheracer in forum Symbian C++
    Replies: 12
    Last Post: 2007-06-25, 15:05
  3. Remove of RPointerarray panics
    By shafali gupta in forum Symbian C++
    Replies: 4
    Last Post: 2007-05-08, 11:43
  4. RPointerArray Remove not working
    By sriramadasu in forum Symbian C++
    Replies: 9
    Last Post: 2007-05-08, 11:42
  5. RPointerArray Remove
    By Vextorin in forum Symbian C++
    Replies: 1
    Last Post: 2004-07-08, 19:59

Posting Permissions

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