[3.0] Change CustomActorImpl destructor to protected 35/100235/2
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Thu, 24 Nov 2016 17:41:45 +0000 (17:41 +0000)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 25 Nov 2016 10:37:56 +0000 (02:37 -0800)
This is a ref-counted object so another non-deriving object should not be able to delete it.

Change-Id: Iacca4e57bc7871c33d0c3602051e2980037de20f

automated-tests/src/dali/utc-Dali-CustomActor.cpp
dali/public-api/actors/custom-actor-impl.cpp
dali/public-api/actors/custom-actor-impl.h

index 347ef03..c32c8e7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -823,7 +823,7 @@ int UtcDaliCustomActorImplDestructor(void)
 {
   TestApplication application;
   CustomActorImpl* actor = new Impl::TestCustomActor();
-  delete actor;
+  CustomActor customActor( *actor ); // Will automatically unref at the end of this function
 
   DALI_TEST_CHECK( true );
   END_TEST;
@@ -1747,12 +1747,12 @@ int UtcDaliCustomActorImplOnPropertySet(void)
 {
   TestApplication application;
   CustomActorImpl* impl = new Impl::SimpleTestCustomActor();
+  CustomActor customActor( *impl ); // Will automatically unref at the end of this function
 
   impl->OnPropertySet( 0, 0 );
 
   DALI_TEST_CHECK( true );
 
-  delete impl;
   END_TEST;
 }
 
index 08022ba..5170eba 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 namespace Dali
 {
 
-CustomActorImpl::~CustomActorImpl()
-{
-}
-
 CustomActor CustomActorImpl::Self() const
 {
   return CustomActor(mOwner);
@@ -44,6 +40,10 @@ CustomActorImpl::CustomActorImpl( ActorFlags flags )
 {
 }
 
+CustomActorImpl::~CustomActorImpl()
+{
+}
+
 void CustomActorImpl::Initialize(Internal::CustomActor& owner)
 {
   DALI_ASSERT_DEBUG(mOwner == NULL); // should not already be owned
index f1d8ed8..fadf9b5 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_CUSTOM_ACTOR_IMPL_H__
 
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -68,12 +68,6 @@ public:
   class Extension; ///< Forward declare future extension interface
 
   /**
-   * @brief Virtual destructor
-   * @SINCE_1_0.0
-   */
-  virtual ~CustomActorImpl();
-
-  /**
    * @brief Used by derived CustomActorImpl instances, to access the public Actor interface.
    *
    * @SINCE_1_0.0
@@ -344,6 +338,12 @@ protected: // For derived classes
    */
   CustomActorImpl( ActorFlags flags );
 
+  /**
+   * @brief Virtual destructor
+   * @SINCE_1_0.0
+   */
+  virtual ~CustomActorImpl();
+
   // Size negotiation helpers
 
   /**