×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Problem and solution

    Problem was that a large app would hang when running on a specific platform (Symbian N97 mini).

    After following up false leads for a week, I finally started inserting trace statements into the code, and slowly narrowed it down to one routine that was doing a lot of dynamic_cast operations from QWidget to subclasses of the same. Often these casts were "wrong" and they looked for a null/non-null result to indicate which class was which.

    Replaced the dynamic_cast operations with qobject_cast and the problem went away.

    I'm guessing that parts of the C++ support on the box were not compiled with RTTI enabled.

  2. #2
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Problem and solution

    The qobject_cast() function behaves similarly to the standard C++ dynamic_cast(), with the advantages that it doesn't require RTTI support and it works across dynamic library boundaries.

  3. #3
    Regular Contributor
    Join Date
    Sep 2008
    Posts
    286

    Re: Problem and solution

    Hi, Symbian based devices don't have RTTI enabled (never has). Why it worked at all is the worrying part as I've seen rare and very hard to reproduce crashes caused by someone using dynamic_cast.
    grep for dynamic_cast now!

  4. #4
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Problem and solution

    Odd thing is that dynamic_cast is used all over the place in Symbian code.

  5. #5
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Problem and solution

    Runtime type information

    Symbian OS supports runtime type information (RTTI) only from Symbian OS v9 onwards. In Maemo, run time type information was available since the beginning. In both cases, the dynamic_cast operator is used to retrieve RTTI.
    http://wiki.maemo.org/Documentation/...an_OS_Concepts

  6. #6
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Problem and solution

    This idiom appears in hundreds of applications:
    Code:
    CAknAppUi* appUi = dynamic_cast<caknappui *>( CEikonEnv::Static()->AppUi() );
    Presumably it's not a problem??

  7. #7
    Regular Contributor
    Join Date
    Sep 2008
    Posts
    286

    Re: Problem and solution

    argh.. reply lost...

    Symbian indeed does support RTTI but that doesn't mean that has to be enabled. At the time it was introduced to Symbian I was always told that it won't be enabled at for s60 devices and thus you couldn't use dynamic_cast anyways (still a good advice to thumb down object size). I searched against SF codebase and indeed it is full of dynamic_casts so clearly I have old info.

    I have to assume that issues like http://bugreports.qt.nokia.com/browse/QTBUG-7963 are just bugs in it or we failed to enable RTTI for this compilation unit :S

    For your paradigm I've always used static_cast (STATIC_CAST in the old days). This is how Avkon uses it:
    #define iAvkonAppUi ((CAknAppUi*)CEikonEnv::Static()->EikAppUi())

    This article needs updating as well http://wiki.forum.nokia.com/index.ph...ing_in_Symbian ?

Similar Threads

  1. J2ME: Problem in Nokia Solution for a software problem
    By mte01 in forum Mobile Java Tools & SDKs
    Replies: 4
    Last Post: 2011-06-08, 05:52
  2. Replies: 0
    Last Post: 2007-05-16, 11:11
  3. Solution for http problem on new nokia phone
    By wipfunk in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2006-07-20, 05:09
  4. J2ME: Problem in Nokia Solution for a media problem
    By mte01 in forum Mobile Java Tools & SDKs
    Replies: 0
    Last Post: 2005-08-12, 11:30
  5. solution: S60 application icon problem
    By Nokia_Archive in forum Symbian Tools & SDKs
    Replies: 0
    Last Post: 2002-06-03, 02:43

Posting Permissions

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