}
/**
+ * Discard visual from source to visual factory.
+ */
+void DiscardVisual(RegisteredVisualContainer::Iterator sourceIter, RegisteredVisualContainer& source)
+{
+ Toolkit::Visual::Base visual = (*sourceIter)->visual;
+ if(visual)
+ {
+ if(Stage::IsInstalled())
+ {
+ Toolkit::VisualFactory::Get().DiscardVisual(visual);
+ }
+ }
+
+ source.Erase(sourceIter);
+}
+
+/**
* Performs actions as requested using the action name.
* @param[in] object The object on which to perform the action.
* @param[in] actionName The action to perform.
Actor self(mControlImpl.Self());
Toolkit::GetImplementation((*iter)->visual).SetOffScene(self);
(*iter)->pending = false;
- (*iter)->visual.Reset();
- mRemoveVisuals.Erase(iter);
+
+ // Discard removed visual. It will be destroyed at next Idle time.
+ DiscardVisual(iter, mRemoveVisuals);
}
}
{
Toolkit::GetImplementation((*visualToRemoveIter)->visual).SetOffScene(self);
}
- mRemoveVisuals.Erase(visualToRemoveIter);
+
+ // Discard removed visual. It will be destroyed at next Idle time.
+ DiscardVisual(visualToRemoveIter, mRemoveVisuals);
}
// A visual is ready so control may need relayouting if staged
// Visuals pending replacement can now be taken out of the removal list and set off scene
// Iterate through all replacement visuals and add to a move queue then set off scene
- for(auto removalIter = mRemoveVisuals.Begin(), end = mRemoveVisuals.End(); removalIter != end; removalIter++)
+
+ if(!mRemoveVisuals.Empty())
{
- Toolkit::GetImplementation((*removalIter)->visual).SetOffScene(self);
+ std::reverse(mRemoveVisuals.Begin(), mRemoveVisuals.End());
+
+ while(!mRemoveVisuals.Empty())
+ {
+ auto removalIter = mRemoveVisuals.End() - 1u;
+ Toolkit::GetImplementation((*removalIter)->visual).SetOffScene(self);
+
+ // Discard removed visual. It will be destroyed at next Idle time.
+ DiscardVisual(removalIter, mRemoveVisuals);
+ }
}
for(auto replacedIter = mVisuals.Begin(), end = mVisuals.End(); replacedIter != end; replacedIter++)
{
(*replacedIter)->pending = false;
}
-
- mRemoveVisuals.Clear();
}
void Control::Impl::SetMargin(Extents margin)
if(visual)
{
Internal::Visual::Base& visualImpl = Toolkit::GetImplementation(visual);
- return visualImpl.GetPropertyObject(visualPropertyKey);
+ return visualImpl.GetPropertyObject(std::move(visualPropertyKey));
}
Handle handle;