diff --git a/src/common/tbarbase.cpp b/src/common/tbarbase.cpp index 5f4b02fa90..da745d66bc 100644 --- a/src/common/tbarbase.cpp +++ b/src/common/tbarbase.cpp @@ -212,12 +212,20 @@ wxControl *wxToolBarBase::FindControl( int id ) node; node = node->GetNext() ) { - wxControl *control = node->GetData()->GetControl(); - - if (control) + const wxToolBarToolBase * const tool = node->GetData(); + if ( tool->IsControl() ) { - if (control->GetId() == id) + wxControl * const control = tool->GetControl(); + + if ( !control ) + { + wxFAIL_MSG( _T("NULL control in toolbar?") ); + } + else if ( control->GetId() == id ) + { + // found return control; + } } }