Patch #2874 2009-12-27 16:24

techy

OnPageChanged called upon creation (debug2)
Download
2874-OnPageChanged.patch (4.6 KB)
Category
Application::Bugfix
Status
Accepted
Close date
2009-12-31 16:59
Assigned to
mortenmacfly
Index: src/sdk/editorconfigurationdlg.cpp
===================================================================
--- src/sdk/editorconfigurationdlg.cpp    (revision 5986)
+++ src/sdk/editorconfigurationdlg.cpp    (working copy)
@@ -339,7 +339,11 @@
 
 void EditorConfigurationDlg::OnPageChanged(wxListbookEvent& event)
 {
-    UpdateListbookImages();
+    // update only on real change, not on dialog creation
+    if (event.GetOldSelection() != -1 && event.GetSelection() != -1)
+    {
+        UpdateListbookImages();
+    }
 }
 
 void EditorConfigurationDlg::CreateColoursSample()
Index: src/src/compilersettingsdlg.cpp
===================================================================
--- src/src/compilersettingsdlg.cpp    (revision 5986)
+++ src/src/compilersettingsdlg.cpp    (working copy)
@@ -216,7 +216,11 @@
 
 void CompilerSettingsDlg::OnPageChanged(wxListbookEvent& event)
 {
-    UpdateListbookImages();
+    // update only on real change, not on dialog creation
+    if (event.GetOldSelection() != -1 && event.GetSelection() != -1)
+    {
+        UpdateListbookImages();
+    }
 }
 
 void CompilerSettingsDlg::EndModal(int retCode)
Index: src/src/environmentsettingsdlg.cpp
===================================================================
--- src/src/environmentsettingsdlg.cpp    (revision 5986)
+++ src/src/environmentsettingsdlg.cpp    (working copy)
@@ -291,7 +291,11 @@
 
 void EnvironmentSettingsDlg::OnPageChanged(wxListbookEvent& event)
 {
-    UpdateListbookImages();
+    // update only on real change, not on dialog creation
+    if (event.GetOldSelection() != -1 && event.GetSelection() != -1)
+    {
+        UpdateListbookImages();
+    }
 }
 
 void EnvironmentSettingsDlg::OnSetAssocs(wxCommandEvent& event)
Index: src/sdk/finddlg.cpp
===================================================================
--- src/sdk/finddlg.cpp    (revision 5986)
+++ src/sdk/finddlg.cpp    (working copy)
@@ -289,22 +289,23 @@
 
 void FindDlg::OnFindChange(wxNotebookEvent& event)
 {
-    wxComboBox* cmbFind1 = XRCCTRL(*this, "cmbFind1", wxComboBox);
-    wxComboBox* cmbFind2 = XRCCTRL(*this, "cmbFind2", wxComboBox);
+    if (    (event.GetOldSelection() == 0 && event.GetSelection() == 1)
+         || (event.GetOldSelection() == 1 && event.GetSelection() == 0))
+    {
+        wxComboBox* cmbFind1 = XRCCTRL(*this, "cmbFind1", wxComboBox);
+        wxComboBox* cmbFind2 = XRCCTRL(*this, "cmbFind2", wxComboBox);
 
-    if (cmbFind1 && cmbFind2)
-    {
-        if (XRCCTRL(*this, "nbFind", wxNotebook)->GetSelection() == 1)
+        if (event.GetSelection() == 0)
         {
-            cmbFind2->SetValue(cmbFind1->GetValue());
-            cmbFind2->SetFocus();
+            cmbFind1->SetValue(cmbFind2->GetValue());
+            cmbFind1->SetFocus();            
         }
-        else
+        else if (event.GetSelection() == 1)
         {
-            cmbFind1->SetValue(cmbFind2->GetValue());
-            cmbFind1->SetFocus();
+            cmbFind2->SetValue(cmbFind1->GetValue());
+            cmbFind2->SetFocus();            
         }
-    }
+    }    
     event.Skip();
 }
 
Index: src/sdk/replacedlg.cpp
===================================================================
--- src/sdk/replacedlg.cpp    (revision 5986)
+++ src/sdk/replacedlg.cpp    (working copy)
@@ -243,22 +243,27 @@
 
 void ReplaceDlg::OnFindChange(wxNotebookEvent& event)
 {
-    wxComboBox* cmbFind1 = XRCCTRL(*this, "cmbFind1", wxComboBox);
-    wxComboBox* cmbFind2 = XRCCTRL(*this, "cmbFind2", wxComboBox);
+    if (    (event.GetOldSelection() == 0 && event.GetSelection() == 1)
+         || (event.GetOldSelection() == 1 && event.GetSelection() == 0))
+    {
+        wxComboBox* cmbFind1 = XRCCTRL(*this, "cmbFind1", wxComboBox);
+        wxComboBox* cmbFind2 = XRCCTRL(*this, "cmbFind2", wxComboBox);
+        wxComboBox* cmbReplace1 =XRCCTRL(*this, "cmbReplace1", wxComboBox);
+        wxComboBox* cmbReplace2 =XRCCTRL(*this, "cmbReplace2", wxComboBox);
 
-    if (cmbFind1 && cmbFind2)
-    {
-        if (XRCCTRL(*this, "nbReplace", wxNotebook)->GetSelection() == 1)
+        if (event.GetSelection() == 0)
         {
-            cmbFind2->SetValue(cmbFind1->GetValue());
-            cmbFind2->SetFocus();
+            cmbFind1->SetValue(cmbFind2->GetValue());
+            cmbReplace1->SetValue(cmbReplace2->GetValue());
+            cmbFind1->SetFocus();            
         }
-        else
+        else if (event.GetSelection() == 1)
         {
-            cmbFind1->SetValue(cmbFind2->GetValue());
-            cmbFind1->SetFocus();
+            cmbFind2->SetValue(cmbFind1->GetValue());
+            cmbReplace2->SetValue(cmbReplace1->GetValue());
+            cmbFind2->SetFocus();            
         }
-    }
+    }    
     event.Skip();
 }
 
techy 2009-12-27 16:33

EVT_LISTBOOK_PAGE_CHANGED and EVT_NOTEBOOK_PAGE_CHANGED are called even when the tabs are created. In several cases (for instance in the Find dialogue), codeblocks tries to access the other tabs (for instance for search to copy the search string from the other tab), which fails, because they are not created yet. In these situations you don't want the contents of the callback to be executed so I added a check whether we are switching from or switching to an existing tab. The same applies for notebook in settings diologues.

While there, I also made the "replace with" field of replace dialogue to copy the contents when switching between tabs.

mortenmacfly 2009-12-28 19:23

The replace thingy might become a little difficult, as it conflicts with another patch created by rickg22 (multi line replace). However, I hopefully can manage...