OSDN Git Service

プロフィール編集に失敗した場合に「適用」ボタンが無効のまま元に戻らない不具合を修正
authorKimura Youichi <kim.upsilon@bucyou.net>
Sun, 25 Jan 2015 09:15:13 +0000 (18:15 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Sun, 25 Jan 2015 09:24:55 +0000 (18:24 +0900)
OpenTween/ControlTransaction.cs
OpenTween/Resources/ChangeLog.txt
OpenTween/UserInfoDialog.cs

index b9e6317..599710f 100644 (file)
@@ -84,6 +84,20 @@ namespace OpenTween
             return new Transaction<Control>(control, x => x.Cursor = newCursor, x => x.Cursor = oldCursor);
         }
 
+        public static IDisposable Enabled(Control control)
+        {
+            var oldState = control.Enabled;
+
+            return new Transaction<Control>(control, x => x.Enabled = true, x => x.Enabled = oldState);
+        }
+
+        public static IDisposable Disabled(Control control)
+        {
+            var oldState = control.Enabled;
+
+            return new Transaction<Control>(control, x => x.Enabled = false, x => x.Enabled = oldState);
+        }
+
         private class Transaction<T> : IDisposable
         {
             private readonly T control;
index aa2f73f..02b44c0 100644 (file)
@@ -15,6 +15,7 @@
  * FIX: 「発言詳細部・入力欄を発言一覧の下に配置する」設定を変更すると画像投稿ができなくなる不具合を修正
  * FIX: ブラウザパス設定の参照ボタンが動作しなくなっていた不具合を修正
  * FIX: 発言詳細欄からツイート本文をコピーした際に改行が失われてしまう問題を回避
+ * FIX: プロフィール編集に失敗した場合に「適用」ボタンが無効のまま元に戻らない不具合を修正
 
 ==== Ver 1.2.4(2014/11/23)
  * NEW: Mobypicture (mobypicture.com) への画像投稿に対応
index e84e921..a64f999 100644 (file)
@@ -477,90 +477,89 @@ namespace OpenTween
             if (this.twitter.UserId != this._displayUser.Id)
                 return;
 
-            this.ButtonEdit.Enabled = false;
-
-            if (!IsEditing)
+            using (ControlTransaction.Disabled(this.ButtonEdit))
             {
-                ButtonEditText = ButtonEdit.Text;
-                ButtonEdit.Text = Properties.Resources.UserInfoButtonEdit_ClickText1;
+                if (!IsEditing)
+                {
+                    ButtonEditText = ButtonEdit.Text;
+                    ButtonEdit.Text = Properties.Resources.UserInfoButtonEdit_ClickText1;
 
-                TextBoxName.Text = LabelName.Text;
-                TextBoxName.Enabled = true;
-                TextBoxName.Visible = true;
-                LabelName.Visible = false;
+                    TextBoxName.Text = LabelName.Text;
+                    TextBoxName.Enabled = true;
+                    TextBoxName.Visible = true;
+                    LabelName.Visible = false;
 
-                TextBoxLocation.Text = LabelLocation.Text;
-                TextBoxLocation.Enabled = true;
-                TextBoxLocation.Visible = true;
-                LabelLocation.Visible = false;
+                    TextBoxLocation.Text = LabelLocation.Text;
+                    TextBoxLocation.Enabled = true;
+                    TextBoxLocation.Visible = true;
+                    LabelLocation.Visible = false;
 
-                TextBoxWeb.Text = this._displayUser.Url;
-                TextBoxWeb.Enabled = true;
-                TextBoxWeb.Visible = true;
-                LinkLabelWeb.Visible = false;
+                    TextBoxWeb.Text = this._displayUser.Url;
+                    TextBoxWeb.Enabled = true;
+                    TextBoxWeb.Visible = true;
+                    LinkLabelWeb.Visible = false;
 
-                TextBoxDescription.Text = this._displayUser.Description;
-                TextBoxDescription.Enabled = true;
-                TextBoxDescription.Visible = true;
-                DescriptionBrowser.Visible = false;
+                    TextBoxDescription.Text = this._displayUser.Description;
+                    TextBoxDescription.Enabled = true;
+                    TextBoxDescription.Visible = true;
+                    DescriptionBrowser.Visible = false;
 
-                TextBoxName.Focus();
-                TextBoxName.Select(TextBoxName.Text.Length, 0);
+                    TextBoxName.Focus();
+                    TextBoxName.Select(TextBoxName.Text.Length, 0);
 
-                IsEditing = true;
-            }
-            else
-            {
-                Task showUserTask = null;
-
-                if (TextBoxName.Modified ||
-                    TextBoxLocation.Modified ||
-                    TextBoxWeb.Modified ||
-                    TextBoxDescription.Modified)
+                    IsEditing = true;
+                }
+                else
                 {
-                    try
-                    {
-                        var user = await Task.Run(() =>
-                            this.twitter.PostUpdateProfile(
-                                this.TextBoxName.Text,
-                                this.TextBoxWeb.Text,
-                                this.TextBoxLocation.Text,
-                                this.TextBoxDescription.Text));
-
-                        showUserTask = this.ShowUserAsync(user);
-                    }
-                    catch (WebApiException ex)
+                    Task showUserTask = null;
+
+                    if (TextBoxName.Modified ||
+                        TextBoxLocation.Modified ||
+                        TextBoxWeb.Modified ||
+                        TextBoxDescription.Modified)
                     {
-                        MessageBox.Show(ex.Message);
-                        return;
+                        try
+                        {
+                            var user = await Task.Run(() =>
+                                this.twitter.PostUpdateProfile(
+                                    this.TextBoxName.Text,
+                                    this.TextBoxWeb.Text,
+                                    this.TextBoxLocation.Text,
+                                    this.TextBoxDescription.Text));
+
+                            showUserTask = this.ShowUserAsync(user);
+                        }
+                        catch (WebApiException ex)
+                        {
+                            MessageBox.Show(ex.Message);
+                            return;
+                        }
                     }
-                }
 
-                TextBoxName.Enabled = false;
-                TextBoxName.Visible = false;
-                LabelName.Visible = true;
+                    TextBoxName.Enabled = false;
+                    TextBoxName.Visible = false;
+                    LabelName.Visible = true;
 
-                TextBoxLocation.Enabled = false;
-                TextBoxLocation.Visible = false;
-                LabelLocation.Visible = true;
+                    TextBoxLocation.Enabled = false;
+                    TextBoxLocation.Visible = false;
+                    LabelLocation.Visible = true;
 
-                TextBoxWeb.Enabled = false;
-                TextBoxWeb.Visible = false;
-                LinkLabelWeb.Visible = true;
+                    TextBoxWeb.Enabled = false;
+                    TextBoxWeb.Visible = false;
+                    LinkLabelWeb.Visible = true;
 
-                TextBoxDescription.Enabled = false;
-                TextBoxDescription.Visible = false;
-                DescriptionBrowser.Visible = true;
+                    TextBoxDescription.Enabled = false;
+                    TextBoxDescription.Visible = false;
+                    DescriptionBrowser.Visible = true;
 
-                ButtonEdit.Text = ButtonEditText;
+                    ButtonEdit.Text = ButtonEditText;
 
-                IsEditing = false;
+                    IsEditing = false;
 
-                if (showUserTask != null)
-                    await showUserTask;
+                    if (showUserTask != null)
+                        await showUserTask;
+                }
             }
-
-            this.ButtonEdit.Enabled = true;
         }
 
         private async Task DoChangeIcon(string filename)