- DevelControl::RegisterVisual( *this, index, visual, true );
- DevelControl::EnableVisual( *this, index, false );
+ bool enabled = false; // Disabled by default
+
+ // Unregister the visual with the given index if registered previously
+ if( DevelControl::GetVisual( *this, index ) )
+ {
+ // Check whether it was enabled to ensure we do the same with the new visual we're registering
+ enabled = DevelControl::IsVisualEnabled( *this, index );
+ DevelControl::UnregisterVisual( *this, index );
+ }
+
+ DevelControl::RegisterVisual( *this, index, visual, enabled );