diff -r fb3763350a08 -r 4d54b72983ae idlehomescreen/widgetmanager/src/wmplugin.cpp --- a/idlehomescreen/widgetmanager/src/wmplugin.cpp Fri Jan 22 09:35:14 2010 +0200 +++ b/idlehomescreen/widgetmanager/src/wmplugin.cpp Tue Jan 26 11:48:23 2010 +0200 @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include #include @@ -52,30 +54,47 @@ CWmPlugin::~CWmPlugin() { iPostponedCommand = ENone; + + // delete WM UI resources if ( iViewAppUi ) { if ( iWmMainContainer && IsActive() ) { + // WM is showing. Hide first! iWmMainContainer->SetClosingDown( ETrue ); TRAPD( err, iViewAppUi->ActivateLocalViewL( iPreviousViewUid.iViewUid ); ); if ( KErrNone == err ) { + // wait until previous view is switched on top + // then continue destruction. iWait->Start(); - // remove view from appui - iViewAppUi->RemoveView( - TUid::Uid( EWmMainContainerViewId ) ); } else { - TRAP_IGNORE( iViewAppUi->DeactivateActiveViewL(); ); - iViewAppUi->RemoveFromViewStack( - *iWmMainView, iWmMainContainer ); - delete iWmMainContainer; - iWmMainContainer = NULL; + // try to activate default view + TVwsViewId viewId; + if ( iViewAppUi->GetDefaultViewId( viewId ) != KErrNone ) + { + viewId.iAppUid = iViewAppUi->Application()->AppDllUid(); + viewId.iViewUid = TUid::Uid( 1 ); + } + + TRAPD( err, iViewAppUi->ActivateLocalViewL( viewId.iViewUid ); ); + if ( KErrNone == err ) + { + // wait until previous view is switched on top + // then continue destruction. + iWait->Start(); + } } } - } + // remove view from appui (also deletes it) + iViewAppUi->RemoveView( + TUid::Uid( EWmMainContainerViewId ) ); + } + + // delete other members delete iResourceLoader; delete iEffectManager; delete iPostponedContent; @@ -98,7 +117,6 @@ void CWmPlugin::ConstructL() { iWmMainContainer = NULL; - iWmMainView = NULL; // store static view app ui CEikonEnv* eikonEnv = CEikonEnv::Static(); @@ -120,7 +138,6 @@ CleanupStack::PushL( mainView ); iViewAppUi->AddViewL( mainView ); CleanupStack::Pop( mainView ); - iWmMainView = mainView; } // ---------------------------------------------------------