fix drag-and-drop example crash 36/211536/1
authorjunqing.ma <junqing.ma@samsung.com>
Tue, 6 Aug 2019 08:29:56 +0000 (16:29 +0800)
committerjunqing.ma <junqing.ma@samsung.com>
Tue, 6 Aug 2019 08:29:56 +0000 (16:29 +0800)
Change-Id: Iaa88f4e761f5268d9c2471ae295f09cb18362657

examples/drag-and-drop/drag-and-drop-example.cpp

index ef11be7..07556bf 100755 (executable)
@@ -57,13 +57,17 @@ public:
   DragAndDropExample( Application& application )
   : mApplication( application ),
     mDragIndex(-1),
-    mDragRealIndex(-1),
-    mDroppedFinished(false)
+    mDragRealIndex(-1)
   {
     // Connect to the Application's Init signal
     mApplication.InitSignal().Connect( this, &DragAndDropExample::Create );
   }
 
+  ~DragAndDropExample()
+  {
+    mDragAndDropDetector.DetachAll();
+  }
+
   // The Init signal is received once (only) during the Application lifetime
   void Create( Application& application )
   {
@@ -232,12 +236,9 @@ public:
     k1.Add(1.0f, 1.0f);
 
     Animation dropAnimation = Animation::New(0.5f);
-    dropAnimation.FinishedSignal().Connect(this, &DragAndDropExample::DropAnimationFinished);
     dropAnimation.AnimateBetween(Property(mTextLabel[mDragRealIndex], Actor::Property::POSITION), k0, AlphaFunction::EASE_OUT);
     dropAnimation.AnimateBetween(Property(mTextLabel[mDragRealIndex], DevelActor::Property::OPACITY), k1, AlphaFunction::EASE_OUT);
     dropAnimation.Play();
-
-    mDroppedFinished = true;
   }
 
   void DropAnimationFinished(Animation& animation)
@@ -254,13 +255,6 @@ public:
     DALI_LOG_INFO(gDragAndDropFilter, Debug::General, "---control name is %s---\n", control.GetName().c_str());
 
     control.SetOpacity(1.0f);
-
-    if(mDroppedFinished)
-    {
-      mDragAndDropDetector.DetachAll();
-    }
-
-    mDroppedFinished = false;
   }
 
 private:
@@ -276,8 +270,6 @@ private:
 
   Vector2 mDragLocalPos;
 
-  bool mDroppedFinished;
-
 };
 
 int DALI_EXPORT_API main( int argc, char **argv )