Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

Some UI refactoring/tidy up

<< < (10/13) > >>

Alpha:
The page is still visible after your resequencing.

RemovePage() does work, however, that would take much more effort to work properly (and may introduce a memory leak).  (DeletePage() may be the best choice, but a quick test crashed Code::Blocks - methods try to access the deleted objects.)

dmoore:

--- Quote from: Alpha on September 03, 2012, 07:13:17 am ---The page is still visible after your resequencing.

RemovePage() does work, however, that would take much more effort to work properly (and may introduce a memory leak).  (DeletePage() may be the best choice, but a quick test crashed Code::Blocks - methods try to access the deleted objects.)

--- End quote ---

So I gather this issue predates my recent changes and was actually introduced here

dmoore:
try this:


--- Code: ---Index: src/sdk/findreplacedlg.cpp
===================================================================
--- src/sdk/findreplacedlg.cpp (revision 8351)
+++ src/sdk/findreplacedlg.cpp (working copy)
@@ -194,11 +194,13 @@
         XRCCTRL(*this, "chkFixEOLs2",   wxCheckBox)->Hide();
     }
 
+    m_findPage=0;
     if (findReplaceInFilesOnly)
     {
-        // NOTE (jens#1#): Do not delete, just hide the page, to avoid asserts in debug-mode
+        //Remove, but don't destroy the Find/Replace page until this dialog is destroyed.
         XRCCTRL(*this, "nbReplace", wxNotebook)->SetSelection(1);
-        (XRCCTRL(*this, "nbReplace", wxNotebook)->GetPage(0))->Hide(); // no active editor, so only replace-in-files
+        m_findPage=(XRCCTRL(*this, "nbReplace", wxNotebook)->GetPage(0)); // no active editor, so only replace-in-files
+        (XRCCTRL(*this, "nbReplace", wxNotebook)->RemovePage(0)); // no active editor, so only replace-in-files
         XRCCTRL(*this, "cmbFind2", wxComboBox)->SetFocus();
     }
     else if (m_findReplaceInFilesActive)
@@ -270,6 +272,11 @@
     cfg->Write(CONF_GROUP _T("/regex2"),      XRCCTRL(*this, "chkRegEx2",     wxCheckBox)->GetValue());
     cfg->Write(CONF_GROUP _T("/scope2"),      XRCCTRL(*this, "rbScope2",      wxRadioBox)->GetSelection());
 
+    if(m_findPage!=0)
+    {
+        m_findPage->Destroy();
+    }
+
     Disconnect(XRCID("nbReplace"), wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler(FindReplaceDlg::OnReplaceChange));
 }
 
Index: src/include/findreplacedlg.h
===================================================================
--- src/include/findreplacedlg.h (revision 8351)
+++ src/include/findreplacedlg.h (working copy)
@@ -62,6 +62,7 @@
         void SaveComboValues(wxComboBox* combo, const wxString& configKey);
         bool m_findReplaceInFilesActive;
         bool m_findMode;
+        wxWindow *m_findPage;
 
         DECLARE_EVENT_TABLE()
 };

--- End code ---

Alpha:

--- Quote from: dmoore on September 04, 2012, 07:29:14 pm ---So I gather this issue predates my recent changes and was actually introduced here

--- End quote ---
Sorry; I am not sure why I never noticed this before.

--- Quote from: dmoore on September 04, 2012, 08:00:52 pm ---try this:

--- End quote ---
The page disappears correctly, but you may run into trouble with lines like:

--- Code: ---bool FindReplaceDlg::IsFindInFiles() const
{
    return (m_findReplaceInFilesActive || XRCCTRL(*this, "nbReplace", wxNotebook)->GetSelection() == 1);
}

--- End code ---
and

--- Code: ---    //After hiding/showing panels, redo the layout in the notebook pages
    (XRCCTRL(*this, "nbReplace", wxNotebook)->GetPage(0))->Layout();
    (XRCCTRL(*this, "nbReplace", wxNotebook)->GetPage(1))->Layout();

--- End code ---
because (from what I can tell in the documentation) there now would only exist a single page (GetSelection() would always == 0).


In the find menu, enable regular expressions and search something.  Now open find in files, switch to the find tab, and disable regular expressions.  The direction boxes (incorrectly) remain disabled.

dmoore:

--- Quote from: Alpha on September 05, 2012, 01:01:17 am ---The page disappears correctly, but you may run into trouble with lines like:

--- Code: ---bool FindReplaceDlg::IsFindInFiles() const
{
    return (m_findReplaceInFilesActive || XRCCTRL(*this, "nbReplace", wxNotebook)->GetSelection() == 1);
}

--- End code ---
and

--- Code: ---    //After hiding/showing panels, redo the layout in the notebook pages
    (XRCCTRL(*this, "nbReplace", wxNotebook)->GetPage(0))->Layout();
    (XRCCTRL(*this, "nbReplace", wxNotebook)->GetPage(1))->Layout();

--- End code ---
because (from what I can tell in the documentation) there now would only exist a single page (GetSelection() would always == 0).

In the find menu, enable regular expressions and search something.  Now open find in files, switch to the find tab, and disable regular expressions.  The direction boxes (incorrectly) remain disabled.

--- End quote ---

OK, there were only a few instances of that so I made the needed changes and committed them.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version