Symbian OS - Quick Start

3,165 views
3,002 views

Published on

The quickstart slides contain a quick walkthrough for creating your first project using Carbide.c++ Edition and its new UI-designer (available as a free trial version). The final project will display an image, offer the possibility to enter text and display this text on the screen. A very short overview of relevant Symbian OS topics is given at the appropriate locations. To train your Symbian OS skills, you have to option to complete the challenge, which is a "Guess-a-number"-game. Basic knowledge about Symbian OS is recommended to complete this challenge.
Contents

* Symbian OS naming conventions
* Working with Carbide.c++ Developer Edition
* Creating an S60 project
* Application structure
* Topics: Image control, menu definition, text query dialog, label control
* Short overview about descriptors and leaves

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,165
On SlideShare
0
From Embeds
0
Number of Embeds
44
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Symbian OS - Quick Start

  1. 1. Symbian OS<br />Quickstart andCarbide.c++ UI-Design<br />v2.0a – 21 March 2008<br />
  2. 2. Disclaimer<br />These slides are provided free of charge at http://www.symbianresources.com and are used during Symbian OS courses at the University of Applied Sciences in Hagenberg, Austria ( http://www.fh-hagenberg.at/ )<br />Respecting the copyright laws, you are allowed to use them:<br />for your own, personal, non-commercial use<br />in the academic environment<br />In all other cases (e.g. for commercial training), please contact andreas.jakl@fh-hagenberg.at<br />The correctness of the contents of these materials cannot be guaranteed. Andreas Jakl is not liable for incorrect information or damage that may arise from using the materials.<br />Parts of these materials are based on information from Symbian Press-books published by John Wiley & Sons, Ltd. This document contains copyright materials which are proprietary to Symbian, UIQ, Nokia and SonyEricsson. “S60™” is a trademark of Nokia. “UIQ™” is a trademark of UIQ Technology. Pictures of mobile phones or applications are copyright their respective manufacturers / developers. “Symbian ™”, “Symbian OS ™” and all other Symbian-based marks and logos are trademarks of Symbian Software Limited and are used under license. © Symbian Software Limited 2006. <br />Andreas Jakl, 2007<br />2<br />
  3. 3. Contents<br />Short overviewofbasicconcepts<br />Installingtherequiredtools<br />HelloWorld, Workflow<br />Andreas Jakl, 2007<br />3<br />
  4. 4. Conventions<br />Symbian OS andtheworldof C++<br />Andreas Jakl, 2007<br />4<br />
  5. 5. Whyis Symbian OS different?<br />Standard C++ is different to Symbian OS C++<br />C++ is too manifold for a mobile phone (e.g. complete multiple inheritance)<br />C++ isn&apos;t enough for a mobile phone (no exactly defined data types, no DLLs)<br />Symbian OS was created before exceptions and smart pointers were introduced to C++<br />Different requirements concerning applications, error handling, clean-up and efficiency<br />Andreas Jakl, 2007<br />5<br />
  6. 6. Data Types<br />Own data types to be 100% independent from the compiler (like in OpenGL, ...)<br />Andreas Jakl, 2007<br />6<br />
  7. 7. NamingConventions<br />Why?<br />Make code more self-explaining(“... and where&apos;s this variable coming from?”)<br />Get rid of references using “this-&gt;” for instance variables<br />Important for clean-up(Instance variables stored on the heap have to be deleted in the destructor of your class)<br />Common syntax no matter who developed the code<br />Andreas Jakl, 2007<br />7<br />
  8. 8. Conventions: Variables<br />Enumeration constants<br />Enumeration itself: TDayOfWeek<br />e.g.: EMonday, ESolidBrush<br />Constants<br />Create with #define or const TInt ...<br />e.g.: KMaxFileName, KRgbWhite<br />Instance variables (not static!)<br />e.g.: iPosition, iLabel<br />Andreas Jakl, 2007<br />8<br />
  9. 9. Conventions: Variables<br />Parameters (Arguments)<br />„a“ is for „Argument“. Therefore – no „an“!<br />e.g.: aPosition, aText<br />Automatic variables<br />Without special prefix<br />e.g.: position, text<br />Andreas Jakl, 2007<br />9<br />
  10. 10. Conventions: Classes<br />Classification of categories<br />Indirectly describe properties and behavior<br />Important when creating an instance of the class and for clean-up!<br />No rule without exception (HBufC)<br />Andreas Jakl, 2007<br />10<br />
  11. 11. Conventions: Classes<br />T-Classes<br />Must not own data on the heap: no destructor allowed<br />e.g.: Simple data types of Symbian OS (TBuf, TPoint, (TInt))<br />C-Classes<br />Always create them on the heap (using new())<br />Derived from CBase (compare to Java&apos;s Object)<br />e.g.: CEikLabel, CActive<br />Andreas Jakl, 2007<br />11<br />
  12. 12. Conventions: Classes<br />R-Classes<br />“R” = Handle to an external Resource<br />Typical functions: Open(), Create(), Initialize()<br />Don&apos;t forget: Close with Close() or Release()!<br />e.g.: RFile, RTimer, RWindow<br />M-Classes<br />For abstract interfaces (see Java)<br />Static Classes<br />Without prefix. E.g.: User::After(1000)<br />Andreas Jakl, 2007<br />12<br />
  13. 13. Jump-Start<br />Symbian OS<br />Andreas Jakl, 2007<br />13<br />
  14. 14. IDEs – Carbide.c++<br />Carbide.c++(based on Eclipse)<br />New main development platform<br />Integrates Eclipse with required tools<br />Editions:<br />Express: free<br />Developer: €299, UI-designer, on-device debugging<br />Professional: €1.299, Performance tools<br />OEM: €3999, ROM and JTAG support<br />Andreas Jakl, 2007<br />
  15. 15. Carbide.c++<br />Andreas Jakl, 2007<br />15<br />
  16. 16. S60 SDKs<br />Choose SDK depending on required compatibility and features<br />Binary compatibility break with Symbian OS 9<br />www.forum.nokia.com<br />Andreas Jakl, 2007<br />Commonly used for maximum compatibility<br />
  17. 17. Installation<br />Carbide.c++ 1.3 Developer Edition (orlater / better)http://www.forum.nokia.com/main/resources/tools_and_sdks/carbide/index.html<br />Perl 5.6.x (Set thepath variable!) – not 5.8!http://downloads.activestate.com/ActivePerl/Windows/5.6/ActivePerl-5.6.1.638-MSWin32-x86.msi<br />SDK(s) (S60 3rd Ed. MR)http://forum.nokia.com/info/sw.nokia.com/id/4a7149a5-95a5-4726-913a-3c6f21eb65a5/S60-SDK-0616-3.0-mr.html<br />Andreas Jakl, 2007<br />17<br />
  18. 18. Updating Carbide.c++<br />Go to: Help  Software Updates  Find and Install...<br />Choose: “Search for new features to install”<br />Only use the Carbide.c++ Update Site – do updating from other sites might overwrite Carbide.c++ settings!<br />Andreas Jakl, 2007<br />18<br />!<br />!<br />
  19. 19. Workspace<br />Workspace location:<br />Has to be on the same drive as the SDK ( C:)<br />Must not contain space characters<br />Example: C:SymbianMCxxxxx<br />Andreas Jakl, 2007<br />19<br />!!!<br />
  20. 20. The Challenge<br />Features:<br />Displaying an image<br />Text entry dialog<br />Display text<br />… possible (nearly) without coding with the new UI designer!<br />Andreas Jakl, 2007<br />20<br />
  21. 21. Create newproject<br />File  New  C++ Applicationfor S60 Project<br />Andreas Jakl, 2007<br />21<br />1<br />2<br />
  22. 22. Create newproject<br />Call it: HelloWorld<br />Check againifthepathisreally on the SDK drive (C:) anddoes not containspacecharacters!<br />Andreas Jakl, 2007<br />22<br />!<br />
  23. 23. Phone Build<br />Build configurations:<br />WINSCW: Build for the windows-based emulator<br />ARMV5: Optimized builds for the device using the ARM RealView-compiler (commercial)<br />GCCE: Standard builds for the device using the free GCC(E) compiler. Comes with the SDK<br />Andreas Jakl, 2007<br />23<br />
  24. 24. Choose UI-Design<br />Select the empty design<br />The predefined ones don’t fit our requirements!<br />Andreas Jakl, 2007<br />24<br />
  25. 25. Application UID (UID3)<br />Development for v9: 0xE0000000 - 0xEFFFFFFF<br />Development UID automatically assigned by Carbide<br />Get UIDs for public applications:<br />Different range for signed / unsigned<br />Get one for free at: http://www.symbiansigned.com/<br />Andreas Jakl, 2007<br />25<br />
  26. 26. Our Project<br />Andreas Jakl, 2007<br />26<br />
  27. 27. Compile<br />First tests<br />Andreas Jakl, 2007<br />27<br />
  28. 28. ChooseBuild Target<br />HelloWorld ActiveBuildConfiguration  Emulator<br />Andreas Jakl, 2007<br />28<br />
  29. 29. Compile Project<br />(optional) Project  Build Project<br />Run  Run HelloWorld Emulator Debug […]<br />Or:<br />Andreas Jakl, 2007<br />29<br />You can only use the mouse to navigate on the screen on touch-enabled emulators! Otherwise, use the buttons below.<br />
  30. 30. Possible Problems<br />Compilation error:<br /> your workspace / project is not on the same drive as the Symbian OS SDK (usually C:)(told you to put it there several times )<br />Andreas Jakl, 2007<br />30<br />***Generating makefiles.<br />bldmake.bat bldfiles WINSCW UDEB <br />WARNING: EPOCROOT does not specify an existing directory<br />BLDMAKE ERROR: Directory &quot;Symbian9.1S60_3rd_MREPOC32&quot; does not exist<br />Total Time: 0 sec<br />===Build Command = build WINSCW UDEB -v===<br />Exec error:Launching failed***build returned with exit value = -1<br />***Stopping. Check the Problems view or Console output for errors.<br />-1<br />
  31. 31. Possible Problems II<br />Emulator starts in text shell mode<br />e.g. if configured like this by previous courses<br />Open [SDK-directory]Dataepoc.ini<br />Comment the entry textshell by putting a # in front of it  #textshell<br />Andreas Jakl, 2007<br />31<br />
  32. 32. Emulator<br />Application added to the end of the list in the “Installat.” folder<br />Can be moved with “Options  Move [to folder]”<br />Useful when working on the same project for more than 10 minutes<br />Andreas Jakl, 2007<br />32<br />
  33. 33. Building for the Device<br />Change build configuration to Phone Release (GCCE)<br />.sisx-file created in /sis/-folder of your project<br />Send to device using PC Suite or Bluetooth<br />Andreas Jakl, 2007<br />33<br />
  34. 34. Automatic Building<br />You might be used to Eclipse displaying errors as you type...<br />... but this is for Java, not for C++!<br />You can still enable automatic compilation on resource change – might be useful for smaller projects<br />Andreas Jakl, 2007<br />34<br />Window  Preferences...  General  Workspace  Build automatically<br />or: Project  Build automatically<br />
  35. 35. Applicationstructure<br />Applicationclass<br />Entry pointfor OS<br />Definesapplication UID<br />CreatesDocumentclass<br />Normallynochangesrequired in here.<br />Andreas Jakl, 2007<br />35<br />
  36. 36. Applicationstructure (2)<br />Documentclass<br />Takes careofdata model<br />CreatesApplication UI (AppUI-class)<br />Usuallynochangesrequired in thisclasseither.<br />Andreas Jakl, 2007<br />36<br />
  37. 37. Application structure (3)<br />AppUI class<br />“Controller” of the app.<br />Not visible itself<br />Manages views (container)<br />General, application-wide event handling (exit, pause, ...)<br />Andreas Jakl, 2007<br />37<br />
  38. 38. Applicationstructure (4)<br />Viewclass<br />Handling of title- andstatuspane<br />Command handling(forthisview)<br />Andreas Jakl, 2007<br />38<br />
  39. 39. Applicationstructure (5)<br />Containerclass<br />Handling of UI components<br />Andreas Jakl, 2007<br />39<br />
  40. 40. App Startup (S60 Views)<br />Andreas Jakl, 2007<br />40<br />CreateDocumentL()<br />CreateAppUiL()<br />ConstructL()<br />DoActivateL()<br />RunApplication<br />Avkon View SwitchingApplication<br />CMyApplication<br />CMyDocument<br />CMyAppUi<br />CMyView1<br />CMyContainer1<br />Avkon<br />CAknViewAppUi<br />CAknApplication<br />CAknDocument<br />CAknView<br />CAknAppUi<br />CAknAppUiBase<br />Uikon<br />CEikAppUi<br />CEikDocument<br />CEikApplication<br />Cone<br />AppArc<br />CCoeAppUi<br />CApaDocument<br />CApaApplication<br />CCoeControl<br />
  41. 41. Displaying an Image<br />UI-Design<br />Andreas Jakl, 2007<br />41<br />
  42. 42. Create an Image<br />Use your favourite tool to create an image<br />e.g. 64x64 px (not 640x480 etc.!)<br />Save as .bmp (Windows Bitmap) to the gfx-folder of your project<br />Andreas Jakl, 2007<br />42<br />1<br />2<br />
  43. 43. Refresh the Project<br />Within Carbide.c++, go to the gfx-folder and press F5 to refresh the directory contents<br />Andreas Jakl, 2007<br />43<br />
  44. 44. Image<br />HelloWorldContainer.uidesign:<br />1.+2. addnewimagecontrol<br />3. Right-click: „Edit Image Property“<br />Andreas Jakl, 2007<br />44<br />1<br />2<br />3<br />
  45. 45. Assign the Picture<br />4. Switch to the .mbm-file (multi-bitmap, .mif is for vector graphics)<br />5. “Edit MBM/MIF File...”<br />6. “Add From Project”<br />7. Choose your picture<br />Andreas Jakl, 2007<br />45<br />4<br />5<br />7<br />6<br />
  46. 46. Assign the Picture II<br />8. Select the picture<br />9. Update the size of the control to match your bitmap size<br />... that’s it!*<br />Andreas Jakl, 2007<br />46<br />8<br />* if the colours are not displayed<br />correctly in the emulator, set the<br />colour depth of the image to 12 bit<br />instead of 8 bit.<br />9<br />
  47. 47. Definethemenu<br />Interaction<br />Andreas Jakl, 2007<br />47<br />
  48. 48. Menu – Our Goal<br />Dialog forenteringyourname<br />Display dialog after selecting a menu item<br />Andreas Jakl, 2007<br />48<br />
  49. 49. Add a dialog<br />Category: Notes and Dialogs<br />Add: Single-line Data Query<br />Edit properties:<br />Name:queryName<br />Prompt: Entername:<br />Andreas Jakl, 2007<br />49<br />
  50. 50. Edit Entry Field<br />Select entryfield in the UI designer<br />Adaptproperties:<br />Name: editName<br />Text: <br />Maximum Length: 20<br />Andreas Jakl, 2007<br />50<br />
  51. 51. Create Menu Item<br />Click on optionsMenu<br />Create item “Enter name …”by clicking into the menu<br />Let Carbide write the code by selecting “Handle ‚selected‘ Event”<br />Andreas Jakl, 2007<br />51<br />1<br />2<br />3<br />
  52. 52. Display the Dialog<br />Dialog display function created by Carbide: RunQueryNameL()<br />Call from menu handler function (HandleEnter_name_MenuItemSelectedL()) through:<br />TBuf&lt;20&gt; userName;TIntreturnCode = RunQueryNameL(userName, ETrue);<br />Andreas Jakl, 2007<br />52<br />
  53. 53. Descriptors<br />Strings in Symbian OS<br />Andreas Jakl, 2007<br />53<br />
  54. 54. Descriptors<br />Why no standard strings?<br />Use minimal memory<br />Efficiency:<br />ROM (Literals: _LIT!) – Stack – Heap?<br />Constant – modifiable?<br />Unicode(TBuf16 – TBuf8)<br />Takes several months to get used to descriptors :-)<br />Andreas Jakl, 2007<br />54<br />
  55. 55. Andreas Jakl, 2007<br />55<br />h<br />e<br />l<br />l<br />o<br /><br />Strings in C<br />char* hello = &quot;hello&quot;;<br />Memory view:<br />Function strlen()<br />Reads from the beginning to &apos;&apos; and counts number of chars<br />char*<br />0x64243184<br />
  56. 56. Pointer Descriptors<br />Comparable to (const) char* of C<br />Can point to text on the heap, stack or ROM<br />Do NOT own the data they point to!<br />Andreas Jakl, 2007<br />56<br />‘H’<br />‘e’<br />‘l’<br />‘l’<br />‘o’<br />Constant:<br />TPtrC<br />0x64243184<br />5<br />ROM, heaporstack<br />iLength(TDesC)<br />iPtr(TPtrC)<br />‘H’<br />‘e’<br />‘l’<br />‘l’<br />‘o’<br />TPtr<br />Modifiable:<br />0x64243184<br />5<br />9<br />ROM, heaporstack<br />iLength(TDesC)<br />iPtr(TPtrC)<br />iMaxLength(TDes)<br />
  57. 57. Buffer Descriptors<br />Comparable to (const) char[]of C<br />Directly contain the string<br />Use C++ templates to specify length (parameter)<br />Andreas Jakl, 2007<br />57<br />TBufC&lt;5&gt;<br />Constant:<br />‘H’<br />5<br />‘e’<br />‘l’<br />‘l’<br />‘o’<br />iLength(TDesC)<br />Modifiable:<br />TBuf&lt;9&gt;<br />9<br />‘H’<br />5<br />‘e’<br />‘l’<br />‘l’<br />‘o’<br />iLength(TDesC)<br />iMaxLength(TDes)<br />
  58. 58. Constant Heap Descriptor<br />Comparable to (char*) malloc(length+1) of C<br />Data is stored on the heap<br />New and easier to use:RBuf (see Descriptors section of this course)<br />Andreas Jakl, 2007<br />58<br />Heap<br />‘H’<br />5<br />‘e’<br />‘l’<br />‘l’<br />‘o’<br />HBufC*<br />0x64243184<br />Same layout as TBufC<br />
  59. 59. Inheritance Hierarchy<br />Abstract base class because of:<br />Generalisation(use base type for parameters!)<br />Provide basic functions shared by all types (e.g. Compare(), Find(), Mid(), ...)<br />Andreas Jakl, 2007<br />59<br />constant<br />modifiable<br />
  60. 60. Literals<br />In reality _LIT is a macro, expands to create a:<br />Constant descriptor, compiled to program binary<br />Not localisable  only use for testing, very simple applications or fixed strings (e.g. for protocols)!<br />_LIT(KHello, “Hello”);<br />Builds a named object called KHello of type TLitC16<br />Stores the string Hello into the object<br />The string is written to the program binary<br />Andreas Jakl, 2007<br />60<br />
  61. 61. Displaying Text<br />Label controlfor<br />Andreas Jakl, 2007<br />61<br />
  62. 62. Adding a Label<br />Category: Controls<br />Add: Label<br />Adaptproperties:<br />Name:labelName<br />Text:<br />AssignchangesbysavingtheUI design<br />Andreas Jakl, 2007<br />62<br />
  63. 63. Change Label Text<br />Text should be changed from within the source code<br />Define new public function in HelloWorldContainer.h:<br />void SetLabelTextL(const TDesC& aText);<br />In this function, set the text and adapt size:<br />iLabelName-&gt;SetTextL(aText);<br />Andreas Jakl, 2007<br />63<br />!<br />
  64. 64. Change Label Text<br />Call our new function in Carbide’s menu item handler-function (in CHelloWorldContainerView):<br />Andreas Jakl, 2007<br />64<br />if (returnCode == EAknSoftkeyOk) {iHelloWorldContainer-&gt; SetLabelTextL(userName); }<br />
  65. 65. Leaves & Panics<br />Veryshortoverviewof…<br />Andreas Jakl, 2007<br />65<br />
  66. 66. Exceptions – Java<br />Try & Catch for handling exceptions<br />Functions can throw “Exceptions”<br />Andreas Jakl, 2007<br />66<br />Calling function<br />Try {<br />int x = Integer.parseInt(“1234”);<br />} catch (NumberFormatException e) {<br />System.out.println(“Unable to convert this String to a number.”);<br />}<br />Integer Class<br />…<br />static intparseIntthrowsNumberFormatException {<br />…<br />}<br />…<br />
  67. 67. Leave – Symbian<br />TRAP(D) catches exceptions (“Leave”)<br />Functions send out leave<br />Function name marked by an L-suffix<br />Andreas Jakl, 2007<br />67<br />The TRAP(D) macros are defined in e32cmn.h<br />Main-Function<br />TRAPD(err, DoExampleL());if (err) { console-&gt;Printf(KTxtFailed, err); }<br />DoExampleL()-Function<br />voidDoExampleL() {RFsfsSession; // Connect to the file serverUser::LeaveIfError(fsSession.Connect()); // …fsSession.Close(); }<br />TRAPD-Makro declares err as TInt and = KErrNone<br />Leaves if the Connect() function does not return KErrNone<br />
  68. 68. Central ExceptionHandling<br />Andreas Jakl, 2007<br />68<br />New (ELeave) …<br /> … NewL() …<br /> … User::Leave() …<br />… ConstructL() …<br />F6L()<br />F7L()<br />F8L()<br />F9L()<br />F5L()<br />F5L() …<br /> … F6L() ….<br />… F8L() ….<br />F3L()<br />F4L()<br />F0L()<br />F2L()<br />… F3L() …<br />F4L() …<br />F1L()<br />TRAPD(err, F2L());<br />if(err) …<br />
  69. 69. Handling Leaves<br />Try to implement central leave-handling<br />If leave not handled by your code  error-message shown by the UI-framework!<br />Therefore: Only handle leaves yourself if they influence your application<br />Andreas Jakl, 2007<br />69<br />
  70. 70. When can a function leave?<br />Caused by your own code:<br />User::Leave(), User::LeaveIfError(), User::LeaveNoMemory() or User::LeaveIfNull()<br />Failed object-construction<br />when using the “new (ELeave)”-operator<br />Calling a function that potentially causes a leave<br />e.g. x-&gt;DoSomethingL()<br />Andreas Jakl, 2007<br />70<br />
  71. 71. Details: Causing a Leave<br />User::Leave(TIntaReason)<br />Error code (aReason) = value that will be received by TRAP<br />Causes leave in any case<br />User::LeaveIfError(TIntaReason)<br />Causes leave if parameter is negative, e.g.:TIntfoundAt = iElementArray.Find(example, aRelation);User::LeaveIfError(foundAt); // Leaves if foundAt == KErrNotFound (-1)<br />User::LeaveNoMemory()<br />Is the same as: User:Leave(KErrNoMem);<br />User::LeaveIfNull(TAny* aPtr)<br />Andreas Jakl, 2007<br />71<br />
  72. 72. TRAP / TRAPD<br />Two trap harness macros:<br />TRAPD: declares the variable in which the leave code is returned<br />TRAP: declare a TIntvariable yourself<br />If a leave occurs inside MayLeaveL(), which is executed inside the harness, the program code will return immediately to the TRAP harness macro<br />The variable result will contain the error code associated with the leave or will be KErrNoneif no leave occured<br />Andreas Jakl, 2007<br />72<br />TRAPD(result, MayLeaveL());<br />if (KErrNone!=result)<br />...<br />is equivalent to:<br />TIntresult;<br />TRAP(result, MayLeaveL());<br />if (KErrNone!=result)<br />...<br />
  73. 73. Panics<br />... cannot be caught and handled!<br />Terminates thread (= usually the whole application)<br />Use them for checking code logic only<br />Can also be sent out by the system for critical errors<br />If a panic happens:<br />Make sure you fix it, as you can’t handle it!<br />Andreas Jakl, 2007<br />73<br />// Stray signal detected!<br />_LIT(KMsgStraySignal, &quot;Stray signal &quot;);<br />User::Panic(KMsgStraySignal, 1); // Panic with code 1<br />
  74. 74. What does a leave look like?<br />Adapt the code:<br />Trap the leave:<br />Andreas Jakl, 2007<br />74<br />void CHelloWorldContainer::SetLabelTextL(const TDesC& aText)<br /> {<br />iLabelName-&gt;SetTextL (aText);<br />User::Leave(KErrAccessDenied);<br /> }<br />TBoolCHelloWorldContainerView::HandleEnter_name_MenuItemSelectedL( TIntaCommand )<br /> {<br /> // […]<br />TRAPD(err, iHelloWorldContainer-&gt;SetLabelTextL(userName));<br /> // [...]<br /> }<br />
  75. 75. What does a panic look like?<br />Adapt the code:<br /> Will crash the emulator in release mode<br />Andreas Jakl, 2007<br />75<br />TBoolCHelloWorldContainerView::HandleEnter_name_MenuItemSelectedL( TIntaCommand )<br /> {<br />TBuf&lt;20&gt; userName;<br />_LIT(KLongText, &quot;This text is too long for a maximum length of 20, so a panic will occur.&quot;);<br />userName.Copy(KLongText);<br /> // [...]<br /> }<br />
  76. 76. What does a panic look like?<br />In debug mode , your app. will be halted and you get more useful information:<br />Andreas Jakl, 2007<br />76<br />USER 11 Panic: See SDK-Help<br />Symbian OS v9.x  Symbian OS reference  System panic reference  USER<br />This panic is raised when any operation that moves or copies data to a 16-bit variant descriptor, causes the length of that descriptor to exceed its maximum length. <br />It may be caused by any of the copying, appending or formatting member functions and, specifically, by the Insert(), Replace(), Fill(), Fillz() and ZeroTerminate() descriptor member functions. It can also be caused by the SetLength() function. See TDes16.<br />
  77. 77. Thanks for your attention<br />That’s it!<br />Andreas Jakl, 2007<br />77<br />

×