uifw/EikStd/coctlsrc/eikspane.cpp
branchRCL_3
changeset 12 941195f2d488
parent 7 08e69e956a8c
child 13 a8834a2e9a96
--- a/uifw/EikStd/coctlsrc/eikspane.cpp	Tue May 11 16:27:42 2010 +0300
+++ b/uifw/EikStd/coctlsrc/eikspane.cpp	Tue May 25 12:58:19 2010 +0300
@@ -3247,7 +3247,65 @@
 		}
 
 	CCoeControl* oldControl = cont->Control();
+	
+	// Make the old control invisible and effectively remove it from data
+    // subscriber's observer array. This ensures that:
+	//
+	// 1. Old control won't receive messages about layout switch etc.
+	// 2. Old control doesn't try to draw. It must be prevented because its
+	//    window might be invalid due to layout change.
+	if ( oldControl )
+	    {
+        oldControl->MakeVisible( EFalse );
+        
+        TInt count = oldControl->CountComponentControls();
+        
+        for ( TInt i = 0; i < count; ++i )
+            {
+            CCoeControl* child = oldControl->ComponentControl( i );
+            
+            if ( child )
+                {
+                child->MakeVisible( EFalse );
+                }
+            }
+	    }
+	
+	// Make the new control visible and so that it gets added to data
+	// subscriber's observer array. This is only done if the new control is
+    // properly constructed before swapping, i.e. it already
+    // has a container window set.
+	if ( aNewControl && aNewControl->DrawableWindow() )
+	    {
+        SetContainersL( *aNewControl, *cont );
+
+        if ( cont->IsVisible() )
+            {
+            aNewControl->MakeVisible( ETrue );
+
+            TInt count = aNewControl->CountComponentControls();
+            
+            for ( TInt i = 0; i < count; ++i )
+                {
+                CCoeControl* child = aNewControl->ComponentControl( i );
+                
+                if ( child )
+                    {
+                    child->MakeVisible( ETrue );
+                    }
+                }
+            }
+	    }
+	
 	cont->SetControl( aNewControl );
+	
+	// ensure that indicator's priorities etc are up-to-date
+	CAknStatusPaneDataSubscriber* subscriber = DataSubscriber();
+	
+	if ( subscriber )
+	    {
+        subscriber->RefreshDataL();
+	    }
 
 	return oldControl;
 	}