×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Jul 2013
    Posts
    73

    Why does DrawText crashes my application.

    Why does this code when executed crashes my application i mean the app closes.

    Code:
    void CMobEyeContainer::Draw( const TRect& aRect ) const
    {
    	// [[[ begin generated region: do not modify [Generated Contents]
    	CWindowGc& gc = SystemGc();
    	gc.SetBrushColor(TRgb(255,127,60));
    	gc.Clear( aRect );
    
    _LIT(opek,"Hello world");
    gc.DrawText(opek,TPoint(30,30));
    
    }
    I am pretty sure that it worked yesterday, but the ui designer deleted my code and i can;t tell if its the same.


    The thing is with those last two lines of code (excluding } ofc ;] )

  2. #2
    Registered User
    Join Date
    Dec 2009
    Posts
    339

    Re: Why does DrawText crashes my application.

    you need to use a font before calling DrawText() method. That's why you are getting panic.

    Code:
    void CMobEyeContainer::Draw( const TRect& aRect ) const
    {
    	// [[[ begin generated region: do not modify [Generated Contents]
    	CWindowGc& gc = SystemGc();
    	gc.SetBrushColor(TRgb(255,127,60));
    	gc.Clear( aRect );
    TFontSpec spec(_L("Arial"),240 );
    	CFont * font=iCoeEnv->CreateScreenFontL(spec);	  
    
    	gc.UseFont(font);
    	
    	_LIT(opek,"Hello world");
    	gc.DrawText(opek,TPoint(30,30));
    	
    	gc.DiscardFont();
    	iCoeEnv->ReleaseScreenFont(font);

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

    Re: Why does DrawText crashes my application.

    Better idea would propably be to use the system fonts, for examples you could use AknLayoutUtils::FontFromId(EAknLogicalFontPrimaryFont); for retrieving teh font

  4. #4
    Registered User
    Join Date
    Jul 2013
    Posts
    73

    Re: Why does DrawText crashes my application.

    Yes i was using custom font in eairlier code but i thought when i delete font specifing code it will use default :P

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

    Re: Why does DrawText crashes my application.

    The default font is a null pointer, and it was using that

    EDIT: by the way 'crashes', Symbian can give you some error messages after you enable it as described in http://developer.nokia.com/Community...ded_panic_code. It works for both the emulators and for the devices.
    And in case of the emulator you may sometimes find the logfile useful too: http://developer.nokia.com/Community/Wiki/Epocwind.out

Similar Threads

  1. Replies: 5
    Last Post: 2009-12-16, 10:25
  2. Application crashes on get
    By mahmoudhadad in forum Bluetooth Technology
    Replies: 2
    Last Post: 2008-07-28, 14:54
  3. Help: Application crashes on N80
    By sd_ozology in forum Mobile Java General
    Replies: 2
    Last Post: 2008-02-06, 16:38
  4. Application crashes (AO)
    By kamalakshan in forum Symbian
    Replies: 3
    Last Post: 2007-10-31, 06:09
  5. Application crashes
    By kamalakshan in forum Symbian
    Replies: 2
    Last Post: 2007-10-24, 18:17

Posting Permissions

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