Author Topic: Subject: Fix segfault when opening 'Skills and stats' window  (Read 393 times)

g_remlin

  • Wayfarer
  • *
  • Posts: 6
    • View Profile
Subject: Fix segfault when opening 'Skills and stats' window
« on: January 12, 2012, 11:30:41 am »
Move message subscription to the end of window post-initialisation.
If a message arrives before post-initialisation has completed, access
to uninitialised variables can occur, causing a segfault.
Make message subscription the very last action.

---
 trunk/src/client/gui/pawsskillwindow.cpp |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/trunk/src/client/gui/pawsskillwindow.cpp b/trunk/src/client/gui/pawsskillwindow.cpp
index 6f0f089..e47bdaf 100644
--- a/trunk/src/client/gui/pawsskillwindow.cpp
+++ b/trunk/src/client/gui/pawsskillwindow.cpp
@@ -93,8 +93,6 @@ bool pawsSkillWindow::PostSetup()
     {
         return false;
     }
-    psengine->GetMsgHandler()->Subscribe(this, MSGTYPE_GUISKILL);
-    psengine->GetMsgHandler()->Subscribe(this, MSGTYPE_FACTION_INFO);
 
     xml =  csQueryRegistry<iDocumentSystem > ( PawsManager::GetSingleton().GetObjectRegistry());
 
@@ -143,6 +141,9 @@ bool pawsSkillWindow::PostSetup()
     currentTab =0;
     previousTab =0;
 
+    psengine->GetMsgHandler()->Subscribe(this, MSGTYPE_GUISKILL);
+    psengine->GetMsgHandler()->Subscribe(this, MSGTYPE_FACTION_INFO);
+
     return true;
 }

bilbous

  • Guest
Re: Subject: Fix segfault when opening 'Skills and stats' window
« Reply #1 on: January 12, 2012, 12:19:43 pm »
Patches are better suited to the bugtracker they might not get noticed here.

g_remlin

  • Wayfarer
  • *
  • Posts: 6
    • View Profile
Re: Subject: Fix segfault when opening 'Skills and stats' window
« Reply #2 on: January 12, 2012, 12:53:20 pm »
I'm not a prospect, this is not for the 'Dev's' (who don't accept patches anyway).
This is here for those that compile their own, and are not on #Planeshift-build when I am...

Aiwendil

  • Hydlaa Citizen
  • *
  • Posts: 463
    • View Profile
Re: Subject: Fix segfault when opening 'Skills and stats' window
« Reply #3 on: January 12, 2012, 01:18:28 pm »
I'm not a prospect, this is not for the 'Dev's' (who don't accept patches anyway).
You are clearly doing it wrong then. In fact it's pretty simple to get "valid" patches submitted in the PS code tree. You just have to argue with some of the devs for years, rant about them whenever possible and make yourself really unpopular. Then your patches get included at once. ;)

weltall

  • Moderator
  • Veteran
  • *
  • Posts: 1671
    • View Profile
    • http://weltall.heliohost.org
Re: Subject: Fix segfault when opening 'Skills and stats' window
« Reply #4 on: January 12, 2012, 01:50:02 pm »
patch are usually accept provided they don't go against the goals and design of the game(and they cannot be configured somehow to go toward that. How the setting should be done depends on the change), they lack proper commenting, they use a wrong style or they don't fix things correctly (fixing the result and not the cause is an example of this)