I have tried creating a surface in a thread using mbm file as follows
void CMyApplication::StartAppThreadFunctionL(TAny* aParam) {
CMyApplication *engine = static_cast<CMyApplication*>(aParam);
_TCHAR szPath[MAX_PATH];
_tcscpy(szPath,_T("E:\\Images\\Library\\1.mbm"));
engine->gsBigThumbnail = new CGapiSurface(engine->m_pGapiDraw);
HRESULT hr = E_FAIL;
hr = engine->gsBigThumbnail->CreateSurface(GDSURFACE_SYSTEMMEMORY, szPath,0); ...
}
When I try to access the engine->gsBigThumbnail in my main process as shown below the program crashes.
hr = pSurface->BltFast(10, 10, gsBigThumbnail, NULL, GDBLTFAST_KEYSRC, NULL);
If I initialise gsBigThumbnail = new CGapiSurface(m_pGapiDraw); in the main process then the line above doesn't crash but returns err GDERR_NOTINITIALIZED. In the thread the CreateSurface returns GD_OK, so I'm assuming it is created fine.
My thread is created as follows:
TInt res = KErrNone;
User::LeaveIfError( res = ProcessPhotos.Create( _L("ProcessPhotos") ,CMyApplication::StartAppThreadFunction, 16384,1024*1024,1024*1024,this)); ProcessPhotos.SetPriority(EPriorityNormal);
ProcessPhotos.Resume();
TInt CMyApplication::StartAppThreadFunction(TAny* aParam) {
CTrapCleanup * cleanup = CTrapCleanup::New();
TInt err;
if( cleanup == NULL )
{
err = KErrNoMemory;
}
else
{
TRAP( err, StartAppThreadFunctionL(aParam) );
}
delete cleanup;
return err;
}
Please advise