Author Topic: Subject: Fix segfault when opening NPC dialog  (Read 243 times)

g_remlin

  • Wayfarer
  • *
  • Posts: 6
    • View Profile
Subject: Fix segfault when opening NPC dialog
« on: January 12, 2012, 11:28:52 am »

NPC dialog causes a segfault by usage of variables which have not
previously been initialised because of failed widgets (Lists,Bubbles).
Check the variables before attempting use.

---
 trunk/src/client/gui/pawsnpcdialog.cpp |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/trunk/src/client/gui/pawsnpcdialog.cpp b/trunk/src/client/gui/pawsnpcdialog.cpp
index de5c7dc..be78a6e 100644
--- a/trunk/src/client/gui/pawsnpcdialog.cpp
+++ b/trunk/src/client/gui/pawsnpcdialog.cpp
@@ -522,20 +522,24 @@ void pawsNpcDialogWindow::SetupWindowWidgets()
         if(border)  border->Hide();
         //if(close_widget) close_widget->Hide();
         if(lists)   lists->Hide();
-        if(bubbles) bubbles->Show();
-        defaultFrame = bubbles->DefaultFrame();
-        Resize();
-        SetSize(defaultFrame.Width(), defaultFrame.Height());
-        MoveTo(0,0);
+       if(bubbles) {
+           bubbles->Show();
+           defaultFrame = bubbles->DefaultFrame();
+           Resize();
+           SetSize(defaultFrame.Width(), defaultFrame.Height());
+           MoveTo(0,0);
+       }
     }
     else
     {
         if(border)  border->Show();
         if(close_widget) close_widget->Show();
-        if(lists)   lists->Show();
         if(bubbles) bubbles->Hide();
-        defaultFrame = lists->DefaultFrame();
-        Resize();
+       if(lists) {
+           lists->Show();
+           defaultFrame = lists->DefaultFrame();
+           Resize();
+       }
     }
 }