class SceneHolder::SceneHolderLifeCycleObserver : public LifeCycleObserver
{
public:
- SceneHolderLifeCycleObserver(Adaptor*& adaptor)
- : mAdaptor(adaptor){};
+ SceneHolderLifeCycleObserver(Adaptor*& adaptor, bool& adaptorStarted)
+ : mAdaptor(adaptor),
+ mAdaptorStarted(adaptorStarted)
+ {
+ }
private: // Adaptor::LifeCycleObserver interface
- void OnStart() override{};
+ void OnStart() override
+ {
+ mAdaptorStarted = true;
+ };
void OnPause() override{};
void OnResume() override{};
- void OnStop() override{};
+ void OnStop() override
+ {
+ // Mark adaptor as stopped;
+ mAdaptorStarted = false;
+ };
void OnDestroy() override
{
mAdaptor = nullptr;
private:
Adaptor*& mAdaptor;
+ bool& mAdaptorStarted;
};
SceneHolder::SceneHolder()
-: mLifeCycleObserver(new SceneHolderLifeCycleObserver(mAdaptor)),
+: mLifeCycleObserver(new SceneHolderLifeCycleObserver(mAdaptor, mAdaptorStarted)),
mLastTouchEvent(),
mLastHoverEvent(),
mId(mSceneHolderCounter++),
mSurface(nullptr),
mAdaptor(nullptr),
mDpi(),
- mIsBeingDeleted(false),
mAdaptorStarted(false),
mVisible(true)
{
mAdaptor->RemoveObserver(*mLifeCycleObserver.get());
mAdaptor->RemoveWindow(this);
- // The event queue is flushed and we wait for the completion of the surface removal
- mAdaptor->DeleteSurface(*mSurface.get());
+ if(mAdaptorStarted)
+ {
+ // The event queue is flushed and we wait for the completion of the surface removal
+ // Note : we don't need to delete surface when adaptor is stopped now.
+ mAdaptor->DeleteSurface(*mSurface.get());
+ }
mAdaptor = nullptr;
}
DALI_ASSERT_DEBUG(mSurface && "Surface needs to be set before calling this method\n");
+ // We can assume that current adaptor is already started now.
mAdaptorStarted = true;
// Create the scene
void SceneHolder::FeedTouchPoint(Dali::Integration::Point& point, int timeStamp)
{
+ if(DALI_UNLIKELY(!mAdaptorStarted))
+ {
+ DALI_LOG_ERROR("Adaptor is stopped, or not be started yet. Ignore this feed.\n");
+ return;
+ }
+
if(timeStamp < 1)
{
timeStamp = TimeService::GetMilliSeconds();
void SceneHolder::FeedWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
{
+ if(DALI_UNLIKELY(!mAdaptorStarted))
+ {
+ DALI_LOG_ERROR("Adaptor is stopped, or not be started yet. Ignore this feed.\n");
+ return;
+ }
+
// Signals can be emitted while processing core events, and the scene holder could be deleted in the signal callback.
// Keep the handle alive until the core events are processed.
Dali::BaseHandle sceneHolder(this);
void SceneHolder::FeedKeyEvent(Dali::Integration::KeyEvent& keyEvent)
{
+ if(DALI_UNLIKELY(!mAdaptorStarted))
+ {
+ DALI_LOG_ERROR("Adaptor is stopped, or not be started yet. Ignore this feed.\n");
+ return;
+ }
+
Dali::PhysicalKeyboard physicalKeyboard = PhysicalKeyboard::Get();
if(physicalKeyboard)
{
void SceneHolder::FeedHoverEvent(Dali::Integration::Point& point)
{
+ if(DALI_UNLIKELY(!mAdaptorStarted))
+ {
+ DALI_LOG_ERROR("Adaptor is stopped, or not be started yet. Ignore this feed.\n");
+ return;
+ }
+
Integration::HoverEvent hoverEvent;
// Signals can be emitted while processing core events, and the scene holder could be deleted in the signal callback.
void SceneHolder::Reset()
{
+ DALI_ASSERT_ALWAYS(mAdaptorStarted && "Adaptor is stopped, or not be started yet!");
+
mCombiner.Reset();
// Any touch listeners should be told of the interruption.
void Resume();
/**
- * @brief Checks whether this scene holder is being deleted in the event thread.
- *
- * @return true if this scene holder is being deleted in the event thread, or false if not.
- */
- bool IsBeingDeleted() const
- {
- return mIsBeingDeleted;
- }
-
- /**
* @brief Informs the scene that the set surface has been rotated.
*
* @param[in] width The width of rotated surface
Uint16Pair mDpi; ///< The DPI for this SceneHolder.
- std::atomic<bool> mIsBeingDeleted; ///< This is set only from the event thread and read only from the render thread
-
- bool mAdaptorStarted : 1; ///< Whether the adaptor has started or not
- bool mVisible : 1; ///< Whether the scene is visible or not
+ bool mAdaptorStarted; ///< Whether the adaptor has started or not
+ bool mVisible : 1; ///< Whether the scene is visible or not
};
} // namespace Adaptor