From 76dc498cd50fb5bc83b3d0a165df17781af35979 Mon Sep 17 00:00:00 2001
From: Andrei Karas <akaras@inbox.ru>
Date: Thu, 21 May 2015 22:00:30 +0300
Subject: Call postInit after each window creation.

---
 src/gui/dialogsmanager.cpp               |  7 ++++++-
 src/gui/widgets/tabs/setup_input.cpp     |  4 ++--
 src/gui/widgets/tabs/setup_theme.cpp     |  8 ++++----
 src/gui/widgets/tabs/setup_video.cpp     | 16 ++++++++--------
 src/gui/windowmanager.cpp                |  1 +
 src/gui/windows/changeemaildialog.cpp    |  1 +
 src/gui/windows/changepassworddialog.cpp |  1 +
 src/gui/windows/charcreatedialog.cpp     |  4 ++--
 src/gui/windows/charselectdialog.cpp     |  9 +++++----
 src/gui/windows/editserverdialog.cpp     |  1 +
 src/gui/windows/mailviewwindow.cpp       |  1 +
 src/gui/windows/mailwindow.cpp           |  4 ++++
 src/gui/windows/registerdialog.cpp       |  1 +
 src/gui/windows/shopwindow.cpp           |  3 ++-
 src/gui/windows/socialwindow.cpp         |  4 ++--
 src/gui/windows/unregisterdialog.cpp     |  1 +
 16 files changed, 42 insertions(+), 24 deletions(-)

(limited to 'src/gui')

diff --git a/src/gui/dialogsmanager.cpp b/src/gui/dialogsmanager.cpp
index 9d2bcb057..eab8c7387 100644
--- a/src/gui/dialogsmanager.cpp
+++ b/src/gui/dialogsmanager.cpp
@@ -101,7 +101,7 @@ Window *DialogsManager::openErrorDialog(const std::string &header,
 {
     if (settings.supportUrl.empty() || config.getBoolValue("hidesupport"))
     {
-        return new OkDialog(header, message,
+        OkDialog *const dialog = new OkDialog(header, message,
             // TRANSLATORS: ok dialog button
             _("Close"),
             DialogType::ERROR,
@@ -109,6 +109,8 @@ Window *DialogsManager::openErrorDialog(const std::string &header,
             ShowCenter_true,
             nullptr,
             260);
+        dialog->postInit();
+        return dialog;
     }
     else
     {
@@ -136,6 +138,7 @@ void DialogsManager::playerDeath()
             ShowCenter_true,
             nullptr,
             260);
+        deathNotice->postInit();
         deathNotice->addActionListener(&postDeathListener);
     }
 }
@@ -167,6 +170,7 @@ void DialogsManager::attributeChanged(const int id,
                     ShowCenter_true,
                     nullptr,
                     260);
+                weightNotice->postInit();
                 weightNotice->addActionListener(
                     &weightListener);
             }
@@ -186,6 +190,7 @@ void DialogsManager::attributeChanged(const int id,
                     ShowCenter_true,
                     nullptr,
                     260);
+                weightNotice->postInit();
                 weightNotice->addActionListener(
                     &weightListener);
             }
diff --git a/src/gui/widgets/tabs/setup_input.cpp b/src/gui/widgets/tabs/setup_input.cpp
index 4eb81bc4a..f1752d781 100644
--- a/src/gui/widgets/tabs/setup_input.cpp
+++ b/src/gui/widgets/tabs/setup_input.cpp
@@ -155,7 +155,7 @@ void Setup_Input::apply()
         const std::string str2 = keyToString(key2);
 
         // TRANSLATORS: input settings error header
-        new OkDialog(_("Key Conflict(s) Detected."),
+        (new OkDialog(_("Key Conflict(s) Detected."),
             // TRANSLATORS: input settings error
             strprintf(_("Conflict \"%s\" and \"%s\" keys. "
             "Resolve them, or gameplay may result in strange behaviour."),
@@ -166,7 +166,7 @@ void Setup_Input::apply()
             Modal_true,
             ShowCenter_true,
             nullptr,
-            260);
+            260))->postInit();
     }
     keyboard.setEnabled(true);
     inputManager.store();
diff --git a/src/gui/widgets/tabs/setup_theme.cpp b/src/gui/widgets/tabs/setup_theme.cpp
index 9efba0897..54015d788 100644
--- a/src/gui/widgets/tabs/setup_theme.cpp
+++ b/src/gui/widgets/tabs/setup_theme.cpp
@@ -307,14 +307,14 @@ void Setup_Theme::action(const ActionEvent &event)
     else if (eventId == ACTION_INFO)
     {
         // TRANSLATORS: theme info dialog header
-        new OkDialog(_("Theme info"), mThemeInfo,
+        (new OkDialog(_("Theme info"), mThemeInfo,
             // TRANSLATORS: ok dialog button
             _("OK"),
             DialogType::OK,
             Modal_false,
             ShowCenter_true,
             nullptr,
-            600);
+            600))->postInit();
     }
 }
 
@@ -340,7 +340,7 @@ void Setup_Theme::apply()
     if (config.getStringValue("theme") != mTheme)
     {
         // TRANSLATORS: theme message dialog
-        new OkDialog(_("Theme Changed"),
+        (new OkDialog(_("Theme Changed"),
             // TRANSLATORS: ok dialog message
             _("Restart your client for the change to take effect."),
             // TRANSLATORS: ok dialog button
@@ -349,7 +349,7 @@ void Setup_Theme::apply()
             Modal_true,
             ShowCenter_true,
             nullptr,
-            260);
+            260))->postInit();
     }
 
     config.setValue("selectedSkin", "");
diff --git a/src/gui/widgets/tabs/setup_video.cpp b/src/gui/widgets/tabs/setup_video.cpp
index c2ee237e5..9acd36f86 100644
--- a/src/gui/widgets/tabs/setup_video.cpp
+++ b/src/gui/widgets/tabs/setup_video.cpp
@@ -243,7 +243,7 @@ void Setup_Video::apply()
         else
         {
             // TRANSLATORS: video settings warning
-            new OkDialog(_("Switching to Full Screen"),
+            (new OkDialog(_("Switching to Full Screen"),
                 // TRANSLATORS: video settings warning
                 _("Restart needed for changes to take effect."),
                 // TRANSLATORS: ok dialog button
@@ -252,7 +252,7 @@ void Setup_Video::apply()
                 Modal_true,
                 ShowCenter_true,
                 nullptr,
-                260);
+                260))->postInit();
         }
 #endif
         config.setValue("screen", fullscreen);
@@ -270,7 +270,7 @@ void Setup_Video::apply()
 
         // OpenGL can currently only be changed by restarting, notify user.
         // TRANSLATORS: video settings warning
-        new OkDialog(_("Changing to OpenGL"),
+        (new OkDialog(_("Changing to OpenGL"),
             // TRANSLATORS: video settings warning
             _("Applying change to OpenGL requires restart."),
             // TRANSLATORS: ok dialog button
@@ -279,7 +279,7 @@ void Setup_Video::apply()
             Modal_true,
             ShowCenter_true,
             nullptr,
-            260);
+            260))->postInit();
     }
 
     mFps = mFpsCheckBox->isSelected() ?
@@ -386,7 +386,7 @@ void Setup_Video::action(const ActionEvent &event)
                     || height < mainGraphics->mActualHeight)
                 {
                     // TRANSLATORS: video settings warning
-                    new OkDialog(_("Screen Resolution Changed"),
+                    (new OkDialog(_("Screen Resolution Changed"),
                         // TRANSLATORS: video settings warning
                        _("Restart your client for the change to take effect.")
                        + std::string("\n") + _("Some windows may be moved to "
@@ -397,12 +397,12 @@ void Setup_Video::action(const ActionEvent &event)
                         Modal_true,
                         ShowCenter_true,
                         nullptr,
-                        260);
+                        260))->postInit();
                 }
                 else
                 {
                     // TRANSLATORS: video settings warning
-                    new OkDialog(_("Screen Resolution Changed"),
+                    (new OkDialog(_("Screen Resolution Changed"),
                         // TRANSLATORS: video settings warning
                         _("Restart your client for the change"
                         " to take effect."),
@@ -412,7 +412,7 @@ void Setup_Video::action(const ActionEvent &event)
                         Modal_true,
                         ShowCenter_true,
                         nullptr,
-                        260);
+                        260))->postInit();
                 }
             }
 #else
diff --git a/src/gui/windowmanager.cpp b/src/gui/windowmanager.cpp
index 4a05d3491..902acb60d 100644
--- a/src/gui/windowmanager.cpp
+++ b/src/gui/windowmanager.cpp
@@ -97,6 +97,7 @@ void WindowManager::createWindows()
     setupWindow = new SetupWindow;
     setupWindow->postInit();
     helpWindow = new HelpWindow;
+    helpWindow->postInit();
     didYouKnowWindow = new DidYouKnowWindow;
     didYouKnowWindow->postInit();
     popupMenu = new PopupMenu;
diff --git a/src/gui/windows/changeemaildialog.cpp b/src/gui/windows/changeemaildialog.cpp
index fcfd0bfd3..4ab2c690c 100644
--- a/src/gui/windows/changeemaildialog.cpp
+++ b/src/gui/windows/changeemaildialog.cpp
@@ -170,6 +170,7 @@ void ChangeEmailDialog::action(const ActionEvent &event)
                 ShowCenter_true,
                 nullptr,
                 260);
+            dlg->postInit();
             dlg->addActionListener(mWrongDataNoticeListener);
         }
         else
diff --git a/src/gui/windows/changepassworddialog.cpp b/src/gui/windows/changepassworddialog.cpp
index 3fae963ed..ed6ac578b 100644
--- a/src/gui/windows/changepassworddialog.cpp
+++ b/src/gui/windows/changepassworddialog.cpp
@@ -160,6 +160,7 @@ void ChangePasswordDialog::action(const ActionEvent &event)
                 ShowCenter_true,
                 nullptr,
                 260);
+            dlg->postInit();
             dlg->addActionListener(mWrongDataNoticeListener);
         }
         else
diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp
index 4b10d5cf3..d6bc01e95 100644
--- a/src/gui/windows/charcreatedialog.cpp
+++ b/src/gui/windows/charcreatedialog.cpp
@@ -373,7 +373,7 @@ void CharCreateDialog::action(const ActionEvent &event)
         else
         {
             // TRANSLATORS: char creation error
-            new OkDialog(_("Error"),
+            (new OkDialog(_("Error"),
                 // TRANSLATORS: char creation error
                 _("Your name needs to be at least 4 characters."),
                 // TRANSLATORS: ok dialog button
@@ -382,7 +382,7 @@ void CharCreateDialog::action(const ActionEvent &event)
                 Modal_true,
                 ShowCenter_true,
                 nullptr,
-                260);
+                260))->postInit();;
         }
     }
     else if (id == "cancel")
diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp
index 9b03528ec..c6e040065 100644
--- a/src/gui/windows/charselectdialog.cpp
+++ b/src/gui/windows/charselectdialog.cpp
@@ -276,14 +276,14 @@ void CharSelectDialog::action(const ActionEvent &event)
                 character->data.mAttributes[Attributes::EXP]),
                 Units::formatCurrency(
                 character->data.mAttributes[Attributes::MONEY]).c_str());
-            new OkDialog(data->getName(), msg,
+            (new OkDialog(data->getName(), msg,
                 // TRANSLATORS: ok dialog button
                 _("OK"),
                 DialogType::SILENCE,
                 Modal_true,
                 ShowCenter_true,
                 nullptr,
-                260);
+                260))->postInit();
         }
     }
     if (eventId == "switch")
@@ -321,14 +321,14 @@ void CharSelectDialog::action(const ActionEvent &event)
             else
             {
                 // TRANSLATORS: error message
-                new OkDialog(_("Error"), _("Incorrect password"),
+                (new OkDialog(_("Error"), _("Incorrect password"),
                     // TRANSLATORS: ok dialog button
                     _("OK"),
                     DialogType::ERROR,
                     Modal_true,
                     ShowCenter_true,
                     nullptr,
-                    260);
+                    260))->postInit();
             }
         }
         mDeleteIndex = -1;
@@ -346,6 +346,7 @@ void CharSelectDialog::use(const int selected)
     {
         CharCreateDialog *const charCreateDialog =
             new CharCreateDialog(this, selected);
+        charCreateDialog->postInit();
         mCharServerHandler->setCharCreateDialog(charCreateDialog);
     }
 }
diff --git a/src/gui/windows/editserverdialog.cpp b/src/gui/windows/editserverdialog.cpp
index 5444f2107..5f22a5389 100644
--- a/src/gui/windows/editserverdialog.cpp
+++ b/src/gui/windows/editserverdialog.cpp
@@ -221,6 +221,7 @@ void EditServerDialog::action(const ActionEvent &event)
                 ShowCenter_true,
                 nullptr,
                 260);
+            dlg->postInit();
             dlg->addActionListener(this);
         }
         else
diff --git a/src/gui/windows/mailviewwindow.cpp b/src/gui/windows/mailviewwindow.cpp
index 1fc38c2a9..023ea925a 100644
--- a/src/gui/windows/mailviewwindow.cpp
+++ b/src/gui/windows/mailviewwindow.cpp
@@ -183,6 +183,7 @@ void MailViewWindow::action(const ActionEvent &event)
         if (mailEditWindow)
             mailEditWindow->scheduleDelete();
         mailEditWindow = new MailEditWindow;
+        mailEditWindow->postInit();
         mailEditWindow->setTo(mMessage->sender);
         mailEditWindow->setSubject("Re:" + mMessage->title);
         mailEditWindow->setMessage(">" + mMessage->text);
diff --git a/src/gui/windows/mailwindow.cpp b/src/gui/windows/mailwindow.cpp
index 18d0626d1..e1edbb74b 100644
--- a/src/gui/windows/mailwindow.cpp
+++ b/src/gui/windows/mailwindow.cpp
@@ -120,7 +120,10 @@ void MailWindow::action(const ActionEvent &event)
     else if (eventId == "new")
     {
         if (!mailEditWindow)
+        {
             mailEditWindow = new MailEditWindow;
+            mailEditWindow->postInit();
+        }
     }
     else if (eventId == "open")
     {
@@ -213,6 +216,7 @@ void MailWindow::showMessage(MailMessage *const mail)
     }
     delete mailViewWindow;
     mailViewWindow = new MailViewWindow(mail);
+    mailViewWindow->postInit();
 }
 
 void MailWindow::viewNext(const int id)
diff --git a/src/gui/windows/registerdialog.cpp b/src/gui/windows/registerdialog.cpp
index e7d9425e1..021ebb938 100644
--- a/src/gui/windows/registerdialog.cpp
+++ b/src/gui/windows/registerdialog.cpp
@@ -247,6 +247,7 @@ void RegisterDialog::action(const ActionEvent &event)
                 ShowCenter_true,
                 nullptr,
                 260);
+            dlg->postInit();
             dlg->addActionListener(mWrongDataNoticeListener);
         }
         else
diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp
index d9e182757..b173da568 100644
--- a/src/gui/windows/shopwindow.cpp
+++ b/src/gui/windows/shopwindow.cpp
@@ -370,7 +370,7 @@ void ShopWindow::action(const ActionEvent &event)
     {
         EditDialog *const dialog = new EditDialog(
             _("Please enter new shop name"), mSellShopName, "OK");
-            dialog->postInit();
+        dialog->postInit();
         shopRenameListener.setDialog(dialog);
         dialog->addActionListener(&shopRenameListener);
     }
@@ -812,6 +812,7 @@ void ShopWindow::showList(const std::string &nick, std::string data)
     {
         data = data.substr(2);
         buyDialog = new BuyDialog(nick);
+        buyDialog->postInit();
     }
     else if (data.find("S1") == 0)
     {
diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp
index 4a32e75a9..83935ed49 100644
--- a/src/gui/windows/socialwindow.cpp
+++ b/src/gui/windows/socialwindow.cpp
@@ -502,7 +502,7 @@ void SocialWindow::showPartyCreate()
     if (localPlayer->getParty())
     {
         // TRANSLATORS: party creation message
-        new OkDialog(_("Create Party"),
+        (new OkDialog(_("Create Party"),
             _("Cannot create party. You are already in a party"),
             // TRANSLATORS: ok dialog button
             _("OK"),
@@ -510,7 +510,7 @@ void SocialWindow::showPartyCreate()
             Modal_true,
             ShowCenter_true,
             this,
-            260);
+            260))->postInit();
         return;
     }
 
diff --git a/src/gui/windows/unregisterdialog.cpp b/src/gui/windows/unregisterdialog.cpp
index 91975510b..c8ec421a5 100644
--- a/src/gui/windows/unregisterdialog.cpp
+++ b/src/gui/windows/unregisterdialog.cpp
@@ -150,6 +150,7 @@ void UnRegisterDialog::action(const ActionEvent &event)
                 ShowCenter_true,
                 nullptr,
                 260);
+            dlg->postInit();
             dlg->addActionListener(mWrongDataNoticeListener);
         }
         else
-- 
cgit v1.2.3-70-g09d2