×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Regular Contributor
    Join Date
    Jun 2003
    Posts
    318

    please help! framework not calling RestoreL!

    I have a problem that has been bugging me for long, so can someone pls help me out?

    I was trying to create a file based store while refering to the GUI Engine example.

    Just like the GUI Engine example, i have specified in my rss file my default document file:
    RESOURCE TBUF { buf="testform"; }

    and i have implemented both my StoreL and RestoreL functions in my document file. The documentation says these 2 things:

    "This application uses the 'default document file' and is created (if it doesn't already exist) by the framework"

    and

    "The framework calls the document's RestoreL function when the application is started. A CStreamStore object representing the default document file, is supplied along with its root stream dictionary."

    Here is my RestoreL:

    void CTestformDocument::RestoreL(const CStreamStore& aStore, const CStreamDictionary& aStreamDic)
    {
    User::InfoPrint(_L("Running RestoreL"));
    }

    The documentation also says that by using SaveL(), the framework wil then call StoreL within the document file. So just like the guiengine example, i place a SaveL() in my AppUi's handlecommand (under "case EEikCmdExit").

    Two things don't happen,
    - My User::InfoPrint message does not appear when starting the app.

    - When i click exit the program hangs, as if the call to SaveL was illegal..... no compilation errors though.

    I'm not even trying to store actual data yet, and i'm already having probs. I don't know what is missing. Please help me as this is rather urgent!!!



    -advo- =(
    Last edited by advocatee; 2003-07-21 at 06:13.

  2. #2
    Super Contributor
    Join Date
    Apr 2003
    Location
    Czech Republic
    Posts
    915
    Try implement also NewDocumentL() function. As I understand it RestoreL is called only if the store exists. If not, NewDocumentL is executed...

  3. #3
    Regular Contributor
    Join Date
    Jun 2003
    Posts
    318
    Hi,

    Thanks a lot for the quick reply.

    Where do i declare/implement NewDocumentL()?

    I do not see it anywhere in the GUI ENGINE example, and there are no search results for NewDocumentL in the SDK.

    - advo -

  4. #4
    Regular Contributor
    Join Date
    Jun 2003
    Posts
    318
    Does anyone know where i should implement NewDocumentL()?

  5. #5
    Super Contributor
    Join Date
    Apr 2003
    Location
    Czech Republic
    Posts
    915
    Hi advocatee,
    yeah it is pretty strange, but I also was unable to find reference using find tool. But nevertheless it is there. Look at CEikDocument class. It is there together with StoreL, RestoreL, etc...

    ----------------from docs:-------------
    void NewDocumentL();

    Description

    Called by the framework to initialise a new default document file. This occurs when the application is started without a file, and there is no existing default document file in the file system.

    This function should set the document model and the default document to some default settings (for example, a default template file).

  6. #6
    Regular Contributor
    Join Date
    Jun 2003
    Posts
    318

    Solution!

    Following is a reply to an email that i wrote to another forum member concerning this problem. The first part of his email solved my problem. Hopefully it will help others, so here it is.. courtesy of kamildobk.... (the questions were asked by me)
    --------------------------------------------------------------------------------

    > Did you manage to solve your problem? I face a similar problem in
    that the
    framework never ever calls RestoreL(),...
    >
    > And whenever i run SaveL(), the emulator crashes.
    >

    If you are developing for Series60 check if your document class is
    derived
    from CEikDocument ( and not from
    CAknDocument ) Sometimes app wizard generates project which are based
    on the
    CAknDocument.

    > Did you solve your problem? If you managed to, i'd be very grateful
    to
    hear about it... I need a solution rather urgently.

    In Series60 everything is ok, but this method does not work in Crystal
    (
    Communicator ) because it seems that StoreL()/RestoreL() are not
    intended
    for saving app state but rather for saving/loading documents. I finally
    managed to store settings in a file using following two methods.

    //----------------------------------------------------------//

    void CMyDoc::LoadSettings()
    {
    CDictionaryStore *IniFile = MyApp()->OpenIniFileLC(
    Process()->FsSession() );

    if ( IniFile->IsPresentL(KUidAddrBook) )
    {
    RDictionaryReadStream ReadStream;
    ReadStream.OpenLC( *IniFile, KUidAddrBook );
    iAddressBook->InternalizeL( ReadStream );
    CleanupStack::PopAndDestroy();
    }

    CleanupStack::PopAndDestroy();
    }

    //----------------------------------------------------------//

    void CMyDoc::SaveSettings()
    {
    CDictionaryStore *IniFile = MyApp()->OpenIniFileLC(
    Process()->FsSession() );

    RDictionaryWriteStream WriteStream;
    WriteStream.AssignLC( *IniFile, KUidAddrBook );
    iAddressBook->ExternalizeL( WriteStream );
    WriteStream.CommitL();
    CleanupStack::PopAndDestroy();

    IniFile->CommitL();
    CleanupStack::PopAndDestroy();
    }

    //----------------------------------------------------------//

    Kamil


    --------------------------------------------------------------------------------


    Alrighty,,

    -advo-

  7. #7
    Super Contributor
    Join Date
    Apr 2003
    Location
    Czech Republic
    Posts
    915
    Well, if you want your store just for saving settings (INI file) then is this approach OK. But I'm not sure if you shouldn't use CDirectFileStore instead of CDictionaryStore if you want to save streams like state / levels of your game...

  8. #8
    Regular Contributor
    Join Date
    Jun 2003
    Posts
    318

    The Data i wish to store....

    hmm

    how do u define 'settings' anyway.

    I'm not sure if i understand 'settings' correctly. My application is supposed to use Bluetooth, so there will be program settings
    such as :

    on/off, this feature enabled, this feature turned off

    and these settings dictate how the program will run(or won't run if its turned off) while the user is not interacting with it.

    These settings i plan to save in the default document file.

    But other than that, there will be the user's personal details, etc, which are mostly text based(name, race, age), and are saved by the user using a form. I'm planning on storing all of them in the same default document file, to make things easier;.

    What do u think? (I'm not very experienced here...)

    -advo-

  9. #9
    Regular Contributor
    Join Date
    Mar 2003
    Posts
    101

    CAknDocument

    I had similar problem and spent hours on a debugger trying to figure out, why framework doesn't call my RestoreL(). I created my application skeleton with AppWizard that generates CAknDocument derived Document class. I found out that, if you use CAknDocument based class you need first to :

    Create RestoreL/StoreL functions:
    Create OpenFileL() function:

    FileStore* CMyDocument::OpenFileL(TBool aDoOpen,const TDesC& aFilename,RFs& aFs)
    {
    return CEikDocument::OpenFileL(aDoOpen, aFilename, aFs);
    }

    And then you need to specify the TBUF resource in your rss file:

    RESOURCE TBUF { buf="testform"; }

    Even if SDK documentation states that leaving it empty is an option, my application failed to call RestoreL unless this resource was defined to some other value than empty string (and consequently paniced on SaveL).

  10. #10
    Regular Contributor
    Join Date
    Jun 2003
    Posts
    318
    bitnir,

    Sorry if i don't answer your question,

    But i have only experience in using the 'default document', (as shown in GuiEngine example)..

    where you do not specify the name of the data file, and the program automatically creates its own data file (default document file?), in the epoc\wins\c\ folder...

    Therefore i did not even have to use OpenFileL, nor did i have to use any resource

    If i remember correctly, all i had to do was to implement StoreL() and RestoreL(),

    and if i'm not wrong, calling SaveL() will automatically call StoreL().

    And i believe this is a read all at once, write all at once, kinda thing.

    So i don't exactly understand u'r problem, hopefully someone else will help you. Anyway I solved my own problem about the framework not calling RestoreL by deriving my document from CEikDocument instead of CAknDocument. See one of the posts b4 this the my full email to kamil about this problem:
    -------------------------------------------------------------------------------
    > Did you manage to solve your problem? I face a similar problem in
    that the
    framework never ever calls RestoreL(),...
    >
    > And whenever i run SaveL(), the emulator crashes.
    >

    If you are developing for Series60 check if your document class is
    derived
    from CEikDocument ( and not from
    CAknDocument ) Sometimes app wizard generates project which are based
    on the
    CAknDocument.
    -------------------------------------------------------------------------------
    - Kev -
    Last edited by advocatee; 2003-08-27 at 08:24.

Posting Permissions

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