[Maps] Modify diposing routines
[platform/core/csapi/tizenfx.git] / src / Tizen.Maps / Tizen.Maps / Polygon.cs
index d01b831..67a606d 100755 (executable)
@@ -51,6 +51,14 @@ namespace Tizen.Maps
         }
 
         /// <summary>
+        /// Destroy the Polygon object.
+        /// </summary>
+        ~Polygon()
+        {
+            Dispose(false);
+        }
+
+        /// <summary>
         /// Adds or removes the clicked event handlers.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
@@ -131,15 +139,16 @@ namespace Tizen.Maps
         /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
         /// </summary>
         /// <param name="disposing">If true, managed and unmanaged resources can be disposed, otherwise only unmanaged resources can be disposed.</param>
+        /// <since_tizen> 3 </since_tizen>
         protected virtual void Dispose(bool disposing)
         {
             if (!_disposedValue)
             {
                 if (disposing)
                 {
-                    _coordinateList.Clear();
+                    _coordinateList?.Clear();
                 }
-                handle.Dispose();
+                handle?.Dispose();
                 _disposedValue = true;
             }
         }