[Problem] Some unsafe handle assignments are allowed by the compiler e.g.
Actor notAnImageActor = Actor::New();
ImageActor notSafeToUse = notAnImageActor;
[Cause] using BaseHandle::operator= is unsafe
[Solution] Implemented the Handle assignment operators properly
Change-Id: I0df98636a08f49afbf195f0ee9f7d4f7bdbfdc5a
{
}
+ColorController& ColorController::operator=(const ColorController& rhs)
+{
+ BaseHandle::operator=(rhs);
+ return *this;
+}
+
+ColorController& ColorController::operator=(BaseHandle::NullType* rhs)
+{
+ DALI_ASSERT_ALWAYS( (rhs == NULL) && "Can only assign NULL pointer to handle");
+ Reset();
+ return *this;
+}
+
ColorController ColorController::Get()
{
return Internal::Adaptor::ColorController::Get();
{
}
+Orientation::Orientation(const Orientation& handle)
+: BaseHandle(handle)
+{
+}
+
+Orientation& Orientation::operator=(const Orientation& rhs)
+{
+ BaseHandle::operator=(rhs);
+ return *this;
+}
+
+Orientation& Orientation::operator=(BaseHandle::NullType* rhs)
+{
+ DALI_ASSERT_ALWAYS( (rhs == NULL) && "Can only assign NULL pointer to handle");
+ Reset();
+ return *this;
+}
+
int Orientation::GetDegrees() const
{
return Internal::Adaptor::GetImplementation(*this).GetDegrees();
return *this;
}
+StyleMonitor& StyleMonitor::operator=(BaseHandle::NullType* rhs)
+{
+ DALI_ASSERT_ALWAYS( (rhs == NULL) && "Can only assign NULL pointer to handle");
+ Reset();
+ return *this;
+}
+
StyleMonitor::StyleMonitor(Internal::Adaptor::StyleMonitor* internal)
: BaseHandle(internal)
{
return *this;
}
+Timer& Timer::operator=(BaseHandle::NullType* rhs)
+{
+ DALI_ASSERT_ALWAYS( (rhs == NULL) && "Can only assign NULL pointer to handle");
+ Reset();
+ return *this;
+}
+
Timer::~Timer()
{
}
{
}
+Window::Window(const Window& handle)
+: BaseHandle(handle)
+{
+}
+
+Window& Window::operator=(const Window& rhs)
+{
+ BaseHandle::operator=(rhs);
+ return *this;
+}
+
+Window& Window::operator=(BaseHandle::NullType* rhs)
+{
+ DALI_ASSERT_ALWAYS( (rhs == NULL) && "Can only assign NULL pointer to handle");
+ Reset();
+ return *this;
+}
+
void Window::SetIndicatorStyle( IndicatorStyle style )
{
GetImplementation(*this).SetIndicatorStyle( style );
ColorController( const ColorController& colorController);
/**
- * @copydoc Dali::BaseHandle::operator=
+ * @brief This assignment operator is required for (smart) pointer semantics.
+ *
+ * @param [in] rhs A reference to the copied handle
+ * @return A reference to this
+ */
+ ColorController& operator=(const ColorController& rhs);
+
+ /**
+ * @brief This method is defined to allow assignment of the NULL value,
+ * and will throw an exception if passed any other value.
+ *
+ * Assigning to NULL is an alias for Reset().
+ * @param [in] rhs A NULL pointer
+ * @return A reference to this handle
*/
- using BaseHandle::operator=;
+ ColorController& operator=(BaseHandle::NullType* rhs);
/**
* @brief Retrieve the initialized instance of the ColorController.
~Orientation();
/**
- * @copydoc Dali::BaseHandle::operator=
+ * @brief This copy constructor is required for (smart) pointer semantics.
+ *
+ * @param [in] handle A reference to the copied handle
+ */
+ Orientation(const Orientation& handle);
+
+ /**
+ * @brief This assignment operator is required for (smart) pointer semantics.
+ *
+ * @param [in] rhs A reference to the copied handle
+ * @return A reference to this
*/
- using BaseHandle::operator=;
+ Orientation& operator=(const Orientation& rhs);
+ /**
+ * @brief This method is defined to allow assignment of the NULL value,
+ * and will throw an exception if passed any other value.
+ *
+ * Assigning to NULL is an alias for Reset().
+ * @param [in] rhs A NULL pointer
+ * @return A reference to this handle
+ */
+ Orientation& operator=(BaseHandle::NullType* rhs);
/**
* @brief Returns the orientation of the device in degrees.
*/
static StyleMonitor DownCast( BaseHandle handle );
- /**
- * @copydoc Dali::BaseHandle::operator=
- */
- using BaseHandle::operator=;
-
public: // Style Information
/**
*/
StyleMonitor& operator=(const StyleMonitor& monitor);
+ /**
+ * @brief This method is defined to allow assignment of the NULL value,
+ * and will throw an exception if passed any other value.
+ *
+ * Assigning to NULL is an alias for Reset().
+ * @param [in] rhs A NULL pointer
+ * @return A reference to this handle
+ */
+ StyleMonitor& operator=(BaseHandle::NullType* rhs);
public: // Not intended for application developers
/**
Timer& operator=( const Timer& timer );
/**
+ * @brief This method is defined to allow assignment of the NULL value,
+ * and will throw an exception if passed any other value.
+ *
+ * Assigning to NULL is an alias for Reset().
+ * @param [in] rhs A NULL pointer
+ * @return A reference to this handle
+ */
+ Timer& operator=(BaseHandle::NullType* rhs);
+
+ /**
* @brief Destructor
*
* This is non-virtual since derived Handle types must not contain data or virtual methods.
static Timer DownCast( BaseHandle handle );
/**
- * @copydoc Dali::BaseHandle::operator=
- */
- using BaseHandle::operator=;
-
- /**
* @brief Start timer.
*
* In case a Timer is already running it's time is reset and timer is restarted.
~Window();
/**
- * @copydoc Dali::BaseHandle::operator=
+ * @brief This copy constructor is required for (smart) pointer semantics.
+ *
+ * @param [in] handle A reference to the copied handle
+ */
+ Window(const Window& handle);
+
+ /**
+ * @brief This assignment operator is required for (smart) pointer semantics.
+ *
+ * @param [in] rhs A reference to the copied handle
+ * @return A reference to this
+ */
+ Window& operator=(const Window& rhs);
+
+ /**
+ * @brief This method is defined to allow assignment of the NULL value,
+ * and will throw an exception if passed any other value.
+ *
+ * Assigning to NULL is an alias for Reset().
+ * @param [in] rhs A NULL pointer
+ * @return A reference to this handle
*/
- using BaseHandle::operator=;
+ Window& operator=(BaseHandle::NullType* rhs);
/**
* @brief This sets the style of indicator