OSDN Git Service

ShowUserInfo.UserPicture で使用中の画像の破棄を Dispose メソッド内で行う
authorKimura Youichi <kim.upsilon@bucyou.net>
Tue, 29 Apr 2014 23:45:49 +0000 (08:45 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Fri, 2 May 2014 20:08:44 +0000 (05:08 +0900)
OpenTween/ShowUserInfo.Designer.cs
OpenTween/ShowUserInfo.cs

index 64fcfc4..353c8e8 100644 (file)
@@ -7,19 +7,6 @@
         /// </summary>
         private System.ComponentModel.IContainer components = null;
 
-        /// <summary>
-        /// Clean up any resources being used.
-        /// </summary>
-        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
-        protected override void Dispose(bool disposing)
-        {
-            if (disposing && (components != null))
-            {
-                components.Dispose();
-            }
-            base.Dispose(disposing);
-        }
-
         #region Windows Form Designer generated code
 
         /// <summary>
             this.ShowInTaskbar = false;
             this.TopMost = true;
             this.Activated += new System.EventHandler(this.ShowUserInfo_Activated);
-            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ShowUserInfo_FormClosing);
             this.Load += new System.EventHandler(this.ShowUserInfo_Load);
             this.Shown += new System.EventHandler(this.ShowUserInfo_Shown);
             this.DragDrop += new System.Windows.Forms.DragEventHandler(this.ShowUserInfo_DragDrop);
index 9f89435..e7c3599 100644 (file)
@@ -345,16 +345,6 @@ namespace OpenTween
                 UserPicture.Invalidate(false);
         }
 
-        private void ShowUserInfo_FormClosing(object sender, FormClosingEventArgs e)
-        {
-            var oldImage = this.UserPicture.Image;
-            if (oldImage != null)
-            {
-                this.UserPicture.Image = null;
-                oldImage.Dispose();
-            }
-        }
-
         private void ShowUserInfo_Shown(object sender, EventArgs e)
         {
             ButtonClose.Focus();
@@ -693,5 +683,23 @@ namespace OpenTween
                 await this.DoChangeIcon(filename);
             }
         }
+
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing)
+            {
+                var oldImage = this.UserPicture.Image;
+                if (oldImage != null)
+                {
+                    this.UserPicture.Image = null;
+                    oldImage.Dispose();
+                }
+
+                if (this.components != null)
+                    this.components.Dispose();
+            }
+
+            base.Dispose(disposing);
+        }
     }
 }