Kirix Support Forums

Remove unused vars

Please post any wxAUI patches or modifications you've created here. Thanks!

Remove unused vars

Postby abligh on Tue Jan 10, 2006 4:20 pm

This patch (against 0.9.1) removes unused variables and the consequent compiler warnings if -Wall if switched on. It is available under the wxWidgets license, of course.

Code: Select all
--- src/manager.cpp.keep        2006-01-10 21:15:34.000000000 +0000
+++ src/manager.cpp     2006-01-10 21:16:49.000000000 +0000
@@ -1815,9 +1815,6 @@
     // create the sizer for the dock
     wxSizer* dock_sizer = new wxBoxSizer(orientation);

-    // this flag determines if there will be space left.
-    bool space_left = true;
-
     // add each pane to the dock
     int pane_i, pane_count = dock.panes.GetCount();

@@ -2178,9 +2175,7 @@
     // create a bunch of box sizers,
     // from the innermost level outwards.
     wxSizer* cont = NULL;
-    wxSizer* top = NULL;
     wxSizer* middle = NULL;
-    wxSizer* bottom = NULL;
     int layer = 0;
     int row, row_count;

@@ -3370,8 +3365,6 @@
         if (part.sizer_item && !part.sizer_item->IsShown())
             continue;

-        int pane_state = (part.pane ? part.pane->state : 0);
-
         switch (part.type)
         {
             case wxDockUIPart::typeDockSizer:
abligh
Registered User
 
Posts: 59
Joined: Sun Jan 01, 2006 2:31 pm

Postby Ben on Wed Jan 11, 2006 12:37 am

Wonderful, thanks. Applied.

Ben
User avatar
Ben
Kirix Support Team
 
Posts: 525
Joined: Mon Dec 19, 2005 6:29 am

Postby Michael on Sat Jan 14, 2006 2:23 pm

Hello,

I have a question concerning the patch. When compiling wxAUI, I get 5 unused variables, but the patch just lists 4.

I also got that one:

wxAUI\manager.cpp: In member function `void wxFrameManager::OnFloatingPaneActivated(wxWindow*)':
wxAUI\manager.cpp:3314: warning: unused variable 'pane'


Looking at the function:

Code: Select all
void wxFrameManager::OnFloatingPaneActivated(wxWindow* wnd)
{
    if (GetFlags() & wxAUI_MGR_ALLOW_ACTIVE_PANE)
    {
        // try to find the pane
        wxPaneInfo& pane = GetPane(wnd);
        wxASSERT_MSG(pane.IsOk(), wxT("Pane window not found"));

        SetActivePane(m_panes, wnd);
        Repaint();
    }
}


I suppose that pane is just used in debugging.

Aynway, it looks a bit strange that 'SetActivePane' uses 'm_panes' and not 'pane'. Is this really correct this way? And is the call to GetPane really necessary then?

Thank you very much.

Best wishes,
Michael
Michael
Registered User
 
Posts: 4
Joined: Sat Jan 14, 2006 2:20 pm

Postby Ben on Sun Jan 15, 2006 12:53 am

Yeah, the code is correct. I suppose the check to make sure the pane exists is a bit pedantic, so I'll take care of the problem by removing the unnecessary code.
Last edited by Ben on Mon Jan 16, 2006 2:08 am, edited 1 time in total.
User avatar
Ben
Kirix Support Team
 
Posts: 525
Joined: Mon Dec 19, 2005 6:29 am

Postby Michael on Sun Jan 15, 2006 2:16 pm

Hello,

Thank you very much for your reply :D .

Best wishes,
Michael
Michael
Registered User
 
Posts: 4
Joined: Sat Jan 14, 2006 2:20 pm

Postby TDragon on Tue May 23, 2006 10:15 am

Not sure if this code has been removed or not (it hasn't been as far as I can tell in the version Code::Blocks IDE uses, possibly an older version), but if you want to keep the sanity check you can just surround those two lines (the one with wxASSERT_MSG and the one directly above it) with #ifdef __WXDEBUG__ / #endif. This is correct because the wxASSERT_MSG macro is only expanded when __WXDEBUG__ is defined, and that assertion is the only place where the "pane" variable might be used.
TDragon
 

Return to wxAUI Patches & Modifications