X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fcontrol%2Fcontrol-data-impl.cpp;h=a8387ee9c556e54516256975ced90b57b15fa275;hp=c5af35e07e8376b9573424e3c739b60e217a8fdc;hb=f03adf37a72ffbbd03e75cc263908aeb368f953c;hpb=fd7b0b94254cb9eef6c411007f9fb10cca71f40c diff --git a/dali-toolkit/internal/controls/control/control-data-impl.cpp b/dali-toolkit/internal/controls/control/control-data-impl.cpp index c5af35e..a8387ee 100755 --- a/dali-toolkit/internal/controls/control/control-data-impl.cpp +++ b/dali-toolkit/internal/controls/control/control-data-impl.cpp @@ -1441,15 +1441,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.