3245 { |
3245 { |
3246 User::Leave( KErrNotFound ); |
3246 User::Leave( KErrNotFound ); |
3247 } |
3247 } |
3248 |
3248 |
3249 CCoeControl* oldControl = cont->Control(); |
3249 CCoeControl* oldControl = cont->Control(); |
|
3250 |
|
3251 // Make the old control invisible and effectively remove it from data |
|
3252 // subscriber's observer array. This ensures that: |
|
3253 // |
|
3254 // 1. Old control won't receive messages about layout switch etc. |
|
3255 // 2. Old control doesn't try to draw. It must be prevented because its |
|
3256 // window might be invalid due to layout change. |
|
3257 if ( oldControl ) |
|
3258 { |
|
3259 oldControl->MakeVisible( EFalse ); |
|
3260 |
|
3261 TInt count = oldControl->CountComponentControls(); |
|
3262 |
|
3263 for ( TInt i = 0; i < count; ++i ) |
|
3264 { |
|
3265 CCoeControl* child = oldControl->ComponentControl( i ); |
|
3266 |
|
3267 if ( child ) |
|
3268 { |
|
3269 child->MakeVisible( EFalse ); |
|
3270 } |
|
3271 } |
|
3272 } |
|
3273 |
|
3274 // Make the new control visible and so that it gets added to data |
|
3275 // subscriber's observer array. This is only done if the new control is |
|
3276 // properly constructed before swapping, i.e. it already |
|
3277 // has a container window set. |
|
3278 if ( aNewControl && aNewControl->DrawableWindow() ) |
|
3279 { |
|
3280 SetContainersL( *aNewControl, *cont ); |
|
3281 |
|
3282 if ( cont->IsVisible() ) |
|
3283 { |
|
3284 aNewControl->MakeVisible( ETrue ); |
|
3285 |
|
3286 TInt count = aNewControl->CountComponentControls(); |
|
3287 |
|
3288 for ( TInt i = 0; i < count; ++i ) |
|
3289 { |
|
3290 CCoeControl* child = aNewControl->ComponentControl( i ); |
|
3291 |
|
3292 if ( child ) |
|
3293 { |
|
3294 child->MakeVisible( ETrue ); |
|
3295 } |
|
3296 } |
|
3297 } |
|
3298 } |
|
3299 |
3250 cont->SetControl( aNewControl ); |
3300 cont->SetControl( aNewControl ); |
|
3301 |
|
3302 // ensure that indicator's priorities etc are up-to-date |
|
3303 CAknStatusPaneDataSubscriber* subscriber = DataSubscriber(); |
|
3304 |
|
3305 if ( subscriber ) |
|
3306 { |
|
3307 subscriber->RefreshDataL(); |
|
3308 } |
3251 |
3309 |
3252 return oldControl; |
3310 return oldControl; |
3253 } |
3311 } |
3254 |
3312 |
3255 |
3313 |