Fix some segmentation faults with the GCPadNew configuration dialog.

Also improve the visual appearance in linux.  I think I have done so without hurting the appearance in windows.


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5348 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Glenn Rice 2010-04-12 20:41:38 +00:00
parent 0b45b3c7a1
commit 448af895d3
4 changed files with 25 additions and 16 deletions

View File

@ -324,6 +324,7 @@ CFrame::CFrame(wxFrame* parent,
, m_ToolBar(NULL), m_ToolBarDebug(NULL), m_ToolBarAui(NULL) , m_ToolBar(NULL), m_ToolBarDebug(NULL), m_ToolBarAui(NULL)
, bFloatLogWindow(false), bFloatConsoleWindow(false) , bFloatLogWindow(false), bFloatConsoleWindow(false)
, m_pStatusBar(NULL), m_GameListCtrl(NULL), m_Panel(NULL) , m_pStatusBar(NULL), m_GameListCtrl(NULL), m_Panel(NULL)
, m_RenderFrame(NULL), m_RenderParent(NULL)
, m_LogWindow(NULL) , m_LogWindow(NULL)
, UseDebugger(_UseDebugger), m_bEdit(false), m_bTabSplit(false), m_bNoDocking(false) , UseDebugger(_UseDebugger), m_bEdit(false), m_bTabSplit(false), m_bNoDocking(false)
, m_bControlsCreated(false), m_StopDlg(NULL) , m_bControlsCreated(false), m_StopDlg(NULL)
@ -756,10 +757,10 @@ bool CFrame::RendererHasFocus()
#ifdef _WIN32 #ifdef _WIN32
// Why doesn't the "else" method below work in windows when called from // Why doesn't the "else" method below work in windows when called from
// Host_RendererHasFocus()? // Host_RendererHasFocus()?
bRendererHasFocus = (m_RenderParent == wxWindow::FindFocus()); bRendererHasFocus = m_RenderParent && (m_RenderParent == wxWindow::FindFocus());
return bRendererHasFocus; return bRendererHasFocus;
#else #else
return m_RenderParent == wxWindow::FindFocus(); return m_RenderParent && (m_RenderParent == wxWindow::FindFocus());
#endif #endif
} }

View File

@ -845,6 +845,7 @@ void CFrame::DoStop()
m_RenderParent->SetCursor(wxCURSOR_ARROW); m_RenderParent->SetCursor(wxCURSOR_ARROW);
if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain) if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
m_RenderFrame->Destroy(); m_RenderFrame->Destroy();
m_RenderParent = NULL;
// Clean framerate indications from the status bar. // Clean framerate indications from the status bar.
m_pStatusBar->SetStatusText(wxT(" "), 0); m_pStatusBar->SetStatusText(wxT(" "), 0);

View File

@ -21,7 +21,7 @@ void PadSettingCheckBox::UpdateValue()
PadSettingChoice::PadSettingChoice( wxWindow* const parent, ControlState& _value, int min, int max ) PadSettingChoice::PadSettingChoice( wxWindow* const parent, ControlState& _value, int min, int max )
: PadSetting(_value) : PadSetting(_value)
, wxChoice( parent, -1, wxDefaultPosition, wxSize( 48, -1 ) ) , wxChoice( parent, -1, wxDefaultPosition, wxSize( 54, -1 ) )
{ {
Append( wxT("0") ); Append( wxT("0") );
for ( ; min<=max; ++min ) for ( ; min<=max; ++min )
@ -180,7 +180,7 @@ void ControlChooser::UpdateGUI()
if ( bound ) ss << bound; else ss << "None"; if ( bound ) ss << bound; else ss << "None";
m_bound_label->SetLabel( wxString::FromAscii(ss.str().c_str()) ); m_bound_label->SetLabel( wxString::FromAscii(ss.str().c_str()) );
textctrl->SetLabel( wxString::FromAscii( control_reference->control_qualifier.name.c_str() ) ); textctrl->SetValue(wxString::FromAscii(control_reference->control_qualifier.name.c_str()));
}; };
void GamepadPage::UpdateGUI() void GamepadPage::UpdateGUI()
@ -229,7 +229,7 @@ void GamepadPage::SetControl( wxCommandEvent& event )
{ {
m_plugin.controls_crit.Enter(); // enter m_plugin.controls_crit.Enter(); // enter
m_control_dialog->control_reference->control_qualifier.name = std::string( m_control_dialog->control_chooser->textctrl->GetLabel().ToAscii() ); m_control_dialog->control_reference->control_qualifier.name = std::string( m_control_dialog->control_chooser->textctrl->GetValue().ToAscii() );
m_control_dialog->control_reference->UpdateControls(); m_control_dialog->control_reference->UpdateControls();
m_control_dialog->control_chooser->UpdateGUI(); m_control_dialog->control_chooser->UpdateGUI();
@ -356,20 +356,21 @@ void ControlDialog::SelectControl( wxCommandEvent& event )
wxString final_label; wxString final_label;
if ( sels.size() == 1 ) if (sels.GetCount() == 0)
return;
if ( sels.GetCount() == 1 )
final_label = names[ sels[0] ]; final_label = names[ sels[0] ];
//else if ( sels.size() == lb->GetCount() ) //else if ( sels.GetCount() == lb->GetCount() )
// final_label = "||"; // final_label = "||";
else else
{ {
final_label = wxT('|'); final_label = wxT('|');
for ( unsigned int i=0; i<sels.size(); ++i ) for ( unsigned int i=0; i<sels.GetCount(); ++i )
final_label += names[ sels[i] ] + wxT('|'); final_label += names[ sels[i] ] + wxT('|');
} }
if (!final_label.CompareTo(wxT("|")))
final_label.Empty();
control_chooser->textctrl->SetLabel( final_label ); control_chooser->textctrl->SetValue( final_label );
// kinda dumb // kinda dumb
wxCommandEvent nullevent; wxCommandEvent nullevent;
@ -397,7 +398,7 @@ ControlChooser::ControlChooser( wxWindow* const parent, ControllerInterface::Con
if ( ref->is_input ) if ( ref->is_input )
for ( unsigned int i = 2; i<5; ++i ) for ( unsigned int i = 2; i<5; ++i )
{ {
wxButton* d_btn = new wxButton( parent, -1, wxChar( '0'+i ), wxDefaultPosition, wxSize(16,-1) ); wxButton* d_btn = new wxButton( parent, -1, wxChar( '0'+i ), wxDefaultPosition, wxSize(20,-1) );
_connect_macro_( d_btn, ConfigDetectControl, wxEVT_COMMAND_BUTTON_CLICKED); _connect_macro_( d_btn, ConfigDetectControl, wxEVT_COMMAND_BUTTON_CLICKED);
button_sizer->Add( d_btn ); button_sizer->Add( d_btn );
} }
@ -562,13 +563,16 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
control_group = group; control_group = group;
static_bitmap = NULL; static_bitmap = NULL;
wxFont m_SmallFont(7, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
for ( unsigned int c = 0; c < group->controls.size(); ++c ) for ( unsigned int c = 0; c < group->controls.size(); ++c )
{ {
wxStaticText* label = new wxStaticText( parent, -1, wxString::FromAscii( group->controls[c]->name )/*.append(wxT(" :"))*/ ); wxStaticText* label = new wxStaticText( parent, -1, wxString::FromAscii( group->controls[c]->name )/*.append(wxT(" :"))*/ );
ControlButton* control_button = new ControlButton( parent, group->controls[c]->control_ref, 80 ); ControlButton* control_button = new ControlButton( parent, group->controls[c]->control_ref, 80 );
control_button->SetFont(m_SmallFont);
controls.push_back( control_button ); controls.push_back( control_button );
ControlButton* adv_button = new ControlButton( parent, group->controls[c]->control_ref, 16, "+" ); ControlButton* adv_button = new ControlButton( parent, group->controls[c]->control_ref, 18, "+" );
adv_button->SetFont(m_SmallFont);
control_buttons.push_back( control_button ); control_buttons.push_back( control_button );
@ -632,6 +636,7 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
static_bitmap = new wxStaticBitmap( parent, -1, bitmap, wxDefaultPosition, wxDefaultSize, wxBITMAP_TYPE_BMP ); static_bitmap = new wxStaticBitmap( parent, -1, bitmap, wxDefaultPosition, wxDefaultSize, wxBITMAP_TYPE_BMP );
PadSettingChoice* threshold_cbox = new PadSettingChoice( parent, group->settings[0]->value, 1, 99 ); PadSettingChoice* threshold_cbox = new PadSettingChoice( parent, group->settings[0]->value, 1, 99 );
// threshold_cbox->SetFont(m_SmallFont);
threshold_cbox->Connect( wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( GamepadPage::AdjustSetting ), (wxObject*)0, (wxEvtHandler*)parent ); threshold_cbox->Connect( wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( GamepadPage::AdjustSetting ), (wxObject*)0, (wxEvtHandler*)parent );
options.push_back( threshold_cbox ); options.push_back( threshold_cbox );
@ -727,7 +732,7 @@ GamepadPage::GamepadPage( wxWindow* parent, Plugin& plugin, const unsigned int p
device_cbox = new wxComboBox( this, -1, wxT(""), wxDefaultPosition, wxSize(128,-1), 0, 0, wxTE_PROCESS_ENTER ); device_cbox = new wxComboBox( this, -1, wxT(""), wxDefaultPosition, wxSize(128,-1), 0, 0, wxTE_PROCESS_ENTER );
wxButton* refresh_button = new wxButton( this, -1, wxT("Refresh"), wxDefaultPosition, wxSize(48,-1) ); wxButton* refresh_button = new wxButton( this, -1, wxT("Refresh"), wxDefaultPosition, wxSize(60,-1) );
#define _connect_macro3_( b, f, c ) (b)->Connect( wxID_ANY, c, wxCommandEventHandler( GamepadPage::f ), (wxObject*)0, (wxEvtHandler*)this ); #define _connect_macro3_( b, f, c ) (b)->Connect( wxID_ANY, c, wxCommandEventHandler( GamepadPage::f ), (wxObject*)0, (wxEvtHandler*)this );
@ -749,7 +754,7 @@ GamepadPage::GamepadPage( wxWindow* parent, Plugin& plugin, const unsigned int p
wxButton* const pload_btn = new wxButton( this, -1, wxT("Load"), wxDefaultPosition, wxSize(48,-1) ); wxButton* const pload_btn = new wxButton( this, -1, wxT("Load"), wxDefaultPosition, wxSize(48,-1) );
wxButton* const psave_btn = new wxButton( this, -1, wxT("Save"), wxDefaultPosition, wxSize(48,-1) ); wxButton* const psave_btn = new wxButton( this, -1, wxT("Save"), wxDefaultPosition, wxSize(48,-1) );
wxButton* const pdelete_btn = new wxButton( this, -1, wxT("Delete"), wxDefaultPosition, wxSize(48,-1) ); wxButton* const pdelete_btn = new wxButton( this, -1, wxT("Delete"), wxDefaultPosition, wxSize(60,-1) );
pload_btn->Connect( wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( GamepadPage::LoadProfile ), pload_btn->Connect( wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( GamepadPage::LoadProfile ),
(wxObject*)0, (wxEvtHandler*)this ); (wxObject*)0, (wxEvtHandler*)this );

View File

@ -88,7 +88,9 @@ Keyboard::Key::Key(Display* const display, KeyCode keycode)
} }
while (keysym == NoSymbol && i < 8); while (keysym == NoSymbol && i < 8);
if (keysym == NoSymbol) // 0x0110ffff is the top of the unicode character range according to keysymdef.h
// although it is probably more than we need.
if (keysym == NoSymbol || keysym > 0x0110ffff)
m_keyname = std::string(); m_keyname = std::string();
else else
m_keyname = std::string(XKeysymToString(keysym)); m_keyname = std::string(XKeysymToString(keysym));