X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fcontrol%2Fcontrol-data-impl.cpp;h=5e94e8f4a33aee4daf994133241fc462528fd81c;hb=refs%2Fchanges%2F59%2F194459%2F2;hp=fcfb147fe631b75c7db8dc2924f78c67a86c94f6;hpb=4fcbbea5dc1fb7667607f663f04e898f0e4086ae;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/controls/control/control-data-impl.cpp b/dali-toolkit/internal/controls/control/control-data-impl.cpp index fcfb147..5e94e8f 100755 --- a/dali-toolkit/internal/controls/control/control-data-impl.cpp +++ b/dali-toolkit/internal/controls/control/control-data-impl.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -476,19 +477,13 @@ void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base // ( If the control has been type registered ) if( visual.GetName().empty() ) { - try + // returns empty string if index is not found as long as index is not -1 + std::string visualName = self.GetPropertyName( index ); + if( !visualName.empty() ) { - std::string visualName = self.GetPropertyName( index ); - if( !visualName.empty() ) - { - DALI_LOG_INFO( gLogFilter, Debug::Concise, "Setting visual name for property %d to %s\n", - index, visualName.c_str() ); - visual.SetName( visualName ); - } - } - catch( Dali::DaliException e ) - { - DALI_LOG_WARNING( "Attempting to register visual without a registered property, index: %d\n", index ); + DALI_LOG_INFO( gLogFilter, Debug::Concise, "Setting visual name for property %d to %s\n", + index, visualName.c_str() ); + visual.SetName( visualName ); } } @@ -1440,15 +1435,35 @@ Toolkit::Internal::LayoutItemPtr Control::Impl::GetLayout() const void Control::Impl::SetLayout( Toolkit::Internal::LayoutItem& layout ) { - DALI_LOG_INFO( gLogFilterLayout, Debug::Verbose, "Control::SetLayout control:%s existing layout:%s\n", + DALI_LOG_INFO( gLogFilterLayout, Debug::Verbose, "Control::SetLayout control:%s replacing existing layout:%s\n", mControlImpl.Self().GetName().c_str(), mLayout?"true":"false" ); + // Check if layout already has an owner. + auto control = Toolkit::Control::DownCast( layout.GetOwner() ); + if ( control ) + { + // If the owner is not this control then the owning control can no longer own it. + Dali::Toolkit::Control handle( mControlImpl.GetOwner() ); + if( control != handle ) + { + DALI_LOG_INFO( gLogFilterLayout, Debug::Verbose, "Control::SetLayout Layout already in use, %s will now have a BinLayout\n", + control.GetName().c_str() ); + Toolkit::BinLayout binLayout = Toolkit::BinLayout::New(); + // Previous owner of the layout gets a BinLayout instead of the layout. + DevelControl::SetLayout( control, binLayout ) ; + } + else + { + return; // layout is already set to this control. + } + } if( mLayout ) { mLayout->Unparent(); mLayout.Reset(); } + mLayout = &layout; auto controlHandle = Toolkit::Control::DownCast( mControlImpl.Self() ); // Get a handle of this control implementation without copying internals. @@ -1457,12 +1472,11 @@ void Control::Impl::SetLayout( Toolkit::Internal::LayoutItem& layout ) void Control::Impl::RemoveLayout() { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::Impl::RemoveLayout\n"); - if( mLayout ) - { - mLayout->Unparent(); - mLayout.Reset(); - } + DALI_LOG_INFO( gLogFilterLayout, Debug::Verbose, "Control::Impl::RemoveLayout\n"); + + Toolkit::BinLayout binLayout = Toolkit::BinLayout::New(); + + mControlImpl.mImpl->SetLayout( GetImplementation( binLayout ) ) ; } void Control::Impl::SetLayoutingRequired( bool layoutingRequired )