Patch #1231 2006-07-22 17:00

kkez

Fix for help plugin crash when only one item in the list
Download
1231-Fix_for_help_p.patch (1.3 KB)
Category
Plugin::Bugfix
Status
Accepted
Close date
2006-07-23 16:31
Assigned to
 
Index: src/plugins/contrib/help_plugin/HelpConfigDialog.cpp
===================================================================
--- src/plugins/contrib/help_plugin/HelpConfigDialog.cpp    (revision 2776)
+++ src/plugins/contrib/help_plugin/HelpConfigDialog.cpp    (working copy)
@@ -282,13 +282,14 @@
 void HelpConfigDialog::UpdateUI(wxUpdateUIEvent &event)
 {
   int sel = XRCCTRL(*this, "lstHelp", wxListBox)->GetSelection();
+  int count = XRCCTRL(*this, "lstHelp", wxListBox)->GetCount();
   XRCCTRL(*this, "btnRename", wxButton)->Enable(sel != -1);
   XRCCTRL(*this, "btnDelete", wxButton)->Enable(sel != -1);
   XRCCTRL(*this, "btnBrowse", wxButton)->Enable(sel != -1);
   XRCCTRL(*this, "txtHelp", wxTextCtrl)->Enable(sel != -1);
   XRCCTRL(*this, "chkDefault", wxCheckBox)->Enable(sel != -1);
-
-  if (sel == -1)
+  
+  if (sel == -1 || count == 1)
   {
       XRCCTRL(*this, "btnUp", wxButton)->Disable();
       XRCCTRL(*this, "btnDown", wxButton)->Disable();
@@ -298,7 +299,7 @@
       XRCCTRL(*this, "btnUp", wxButton)->Disable();
       XRCCTRL(*this, "btnDown", wxButton)->Enable();
   }
-  else if (sel == XRCCTRL(*this, "lstHelp", wxListBox)->GetCount() - 1)
+  else if (sel == count - 1)
   {
       XRCCTRL(*this, "btnUp", wxButton)->Enable();
       XRCCTRL(*this, "btnDown", wxButton)->Disable();