diff -r 08e69e956a8c -r 71dd06cfe933 uifw/EikStd/coctlsrc/aknitemactionmenuregister.cpp --- a/uifw/EikStd/coctlsrc/aknitemactionmenuregister.cpp Wed Mar 31 21:59:52 2010 +0300 +++ b/uifw/EikStd/coctlsrc/aknitemactionmenuregister.cpp Wed Apr 14 16:14:00 2010 +0300 @@ -71,11 +71,34 @@ // --------------------------------------------------------------------------- +// AknItemActionMenuRegister::RemoveConstructingMenuBarOwner +// --------------------------------------------------------------------------- +// +EXPORT_C void AknItemActionMenuRegister::RemoveConstructingMenuBarOwner( + MObjectProvider* aMenuBarOwner ) + { + _AKNTRACE_FUNC_ENTER; + + if ( AppUiSingleClickCompatible() ) + { + AknItemActionMenuRegister* instance( Instance() ); + + if ( instance ) + { + instance->DoRemoveConstructingMenuBarOwner( aMenuBarOwner ); + } + } + + _AKNTRACE_FUNC_EXIT; + } + + +// --------------------------------------------------------------------------- // AknItemActionMenuRegister::RegisterCollectionL // --------------------------------------------------------------------------- // CAknItemActionMenu* AknItemActionMenuRegister::RegisterCollectionL( - MAknCollection& aCollectionState ) + MAknCollection& aCollectionState, MObjectProvider* aMenuBarOwner ) { _AKNTRACE_FUNC_ENTER; @@ -85,7 +108,8 @@ AknItemActionMenuRegister* instance( Instance() ); if ( instance ) { - menu = instance->DoRegisterCollectionL( aCollectionState ); + menu = instance->DoRegisterCollectionL( + aCollectionState, aMenuBarOwner ); } } @@ -320,12 +344,22 @@ // --------------------------------------------------------------------------- // CAknItemActionMenu* AknItemActionMenuRegister::DoRegisterCollectionL( - MAknCollection& aCollectionState ) + MAknCollection& aCollectionState, MObjectProvider* aMenuBarOwner ) { _AKNTRACE_FUNC_ENTER; CAknItemActionMenu* menu( NULL ); - CEikMenuBar* menuBar = FindCurrentMenuBarL(); + CEikMenuBar* menuBar = NULL; + + if ( aMenuBarOwner ) + { + aMenuBarOwner->MopGetObject( menuBar ); + } + + if ( !menuBar ) + { + menuBar = FindCurrentMenuBar(); + } menu = RegisterStateToItemActionMenuL( menuBar, aCollectionState ); _AKNTRACE_FUNC_EXIT; @@ -448,7 +482,7 @@ { _AKNTRACE_FUNC_ENTER; - CEikMenuBar* menuBar = FindCurrentMenuBarL(); + CEikMenuBar* menuBar = FindCurrentMenuBar(); if ( !menuBar || !iRegisterArray->RegisterCollectionObserverL( *menuBar, aObserver ) ) { @@ -751,16 +785,15 @@ // --------------------------------------------------------------------------- -// AknItemActionMenuRegister::FindCurrentMenuBarL +// AknItemActionMenuRegister::FindCurrentMenuBar // --------------------------------------------------------------------------- // -CEikMenuBar* AknItemActionMenuRegister::FindCurrentMenuBarL() +CEikMenuBar* AknItemActionMenuRegister::FindCurrentMenuBar() { _AKNTRACE_FUNC_ENTER; CAknAppUi* appUi = AppUI(); CEikonEnv* eikonEnv( CEikonEnv::Static() ); - TBool isConstructingDialog( EFalse ); CEikMenuBar* menuBar( NULL ); // If overriding menubar owner is set then it's the one to obey. If the @@ -771,34 +804,23 @@ _AKNTRACE_FUNC_EXIT; return OverridingObjectMenuBar(); } - - // Check if there is existing constructing dialog + + // by default choose the current constructing menubar owner if ( iMenuBarOwner ) { - CEikDialog* dialog( NULL ); - iMenuBarOwner->MopGetObjectNoChaining( dialog ); - if ( dialog ) - { - isConstructingDialog = ETrue; - } + menuBar = ConstructingObjectMenuBar(); } - // No constructing dialog - if ( !isConstructingDialog ) + else { // Fetch pointer to dialog that is currently displayed menuBar = DialogMenuBar( appUi ); + // No dialog - pointer to active view menu bar if ( !menuBar ) { menuBar = ViewMenuBar( appUi ); } } - - // Fetch pointer to constructing object menu bar - if ( !menuBar ) - { - menuBar = ConstructingObjectMenuBar(); - } // Finally, if no luck with others, fetch pointer to appUi menu bar. if ( !menuBar && eikonEnv ) @@ -901,31 +923,67 @@ iIsConstructingDialog = ETrue; } } - else if ( !aMenuBarOwner && iIsConstructingDialog ) + + iMenuBarOwner = aMenuBarOwner; + } + + +// --------------------------------------------------------------------------- +// AknItemActionMenuRegister::DoRemoveConstructingMenuBarOwner +// --------------------------------------------------------------------------- +// +void AknItemActionMenuRegister::DoRemoveConstructingMenuBarOwner( + MObjectProvider* aMenuBarOwner ) + { + TInt i = 0; + + // set all references to removed menubar owner to NULL + while ( i < iUnregisteredMenus.Count() ) { - // When setting constructing menubar owner to NULL from a dialog check - // if there is item with the same menubar owner in iUnregisteredMenus - // and try to find correct menubar for it. - for ( TInt i = 0; i < iUnregisteredMenus.Count(); i++ ) + TAknUnregisteredMenuData& data( iUnregisteredMenus[i] ); + + if ( data.iOwner == iMenuBarOwner ) { - TAknUnregisteredMenuData& data( iUnregisteredMenus[ i ] ); - if ( data.iOwner == iMenuBarOwner ) + data.iOwner = iMenuBarOwner = NULL; + + // When setting constructing menubar owner to NULL from a dialog + // check if there is item with the same menubar owner in + // iUnregisteredMenus and try to find correct menubar for it. + if ( iIsConstructingDialog ) { - data.iOwner = iMenuBarOwner = NULL; - CEikMenuBar* menuBar = FindCurrentMenuBarL(); + CEikMenuBar* menuBar = FindCurrentMenuBar(); + if ( menuBar ) { - AddRegisterEntryL( *menuBar, *data.iMenu ); + TRAP_IGNORE( AddRegisterEntryL( *menuBar, *data.iMenu ) ); iUnregisteredMenus.Remove( i ); + continue; } - iIsConstructingDialog = EFalse; - return; } } + + ++i; } - iMenuBarOwner = aMenuBarOwner; + + // NULL also possible references in unregistered observers + for ( i = 0; i < iUnregisteredObservers.Count(); ++i ) + { + TAknUnregisteredObserverData& data( iUnregisteredObservers[i] ); + + if ( data.iOwner == aMenuBarOwner ) + { + data.iOwner = NULL; + } + } + + if ( iMenuBarOwner == aMenuBarOwner ) + { + iIsConstructingDialog = EFalse; + iMenuBarOwner = NULL; + } } + // --------------------------------------------------------------------------- // AknItemActionMenuRegister::TAknUnregisteredObserverData // ::TAknUnregisteredObserverData