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."
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!!!
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...
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).
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.
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...
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...)
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 :
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).
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 -