fix crash caused by cancelling querybitmap dialog; fix crash caused by clicking 'add widget icons' on an empty bitmapcombobox
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57015 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -578,12 +578,16 @@ void BitmapComboBoxWidgetsPage::OnButtonLoadFromFile(wxCommandEvent& WXUNUSED(ev
|
|||||||
if ( sel == wxNOT_FOUND )
|
if ( sel == wxNOT_FOUND )
|
||||||
sel = m_combobox->GetCount();
|
sel = m_combobox->GetCount();
|
||||||
|
|
||||||
m_combobox->Insert(s, QueryBitmap(&s), sel);
|
wxBitmap bmp = QueryBitmap(&s);
|
||||||
|
if (bmp.IsOk())
|
||||||
|
m_combobox->Insert(s, bmp, sel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitmapComboBoxWidgetsPage::OnButtonSetFromFile(wxCommandEvent& WXUNUSED(event))
|
void BitmapComboBoxWidgetsPage::OnButtonSetFromFile(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
m_combobox->SetItemBitmap(m_combobox->GetSelection(), QueryBitmap(NULL));
|
wxBitmap bmp = QueryBitmap(NULL);
|
||||||
|
if (bmp.IsOk())
|
||||||
|
m_combobox->SetItemBitmap(m_combobox->GetSelection(), bmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitmapComboBoxWidgetsPage::OnButtonAddMany(wxCommandEvent& WXUNUSED(event))
|
void BitmapComboBoxWidgetsPage::OnButtonAddMany(wxCommandEvent& WXUNUSED(event))
|
||||||
@@ -661,6 +665,7 @@ void BitmapComboBoxWidgetsPage::LoadWidgetImages( wxArrayString* strings, wxImag
|
|||||||
if ( !wxDir::Exists(fn.GetFullPath()) ||
|
if ( !wxDir::Exists(fn.GetFullPath()) ||
|
||||||
!wxDir::GetAllFiles(fn.GetFullPath(),strings,wxT("*.xpm")) )
|
!wxDir::GetAllFiles(fn.GetFullPath(),strings,wxT("*.xpm")) )
|
||||||
{
|
{
|
||||||
|
// Try ../../samples/widgets/icons
|
||||||
fn.RemoveLastDir();
|
fn.RemoveLastDir();
|
||||||
fn.RemoveLastDir();
|
fn.RemoveLastDir();
|
||||||
fn.AppendDir(wxT("icons"));
|
fn.AppendDir(wxT("icons"));
|
||||||
@@ -693,7 +698,7 @@ void BitmapComboBoxWidgetsPage::LoadWidgetImages( wxArrayString* strings, wxImag
|
|||||||
for ( i=0; i<strings->size(); i++ )
|
for ( i=0; i<strings->size(); i++ )
|
||||||
{
|
{
|
||||||
fn.SetFullName((*strings)[i]);
|
fn.SetFullName((*strings)[i]);
|
||||||
wxString name =fn.GetName();
|
wxString name = fn.GetName();
|
||||||
|
|
||||||
// Handle few exceptions
|
// Handle few exceptions
|
||||||
if ( name == wxT("bmpbtn") )
|
if ( name == wxT("bmpbtn") )
|
||||||
@@ -715,6 +720,11 @@ void BitmapComboBoxWidgetsPage::LoadWidgetImages( wxArrayString* strings, wxImag
|
|||||||
#endif
|
#endif
|
||||||
images->Add(bmp);
|
images->Add(bmp);
|
||||||
(*strings)[i] = name;
|
(*strings)[i] = name;
|
||||||
|
|
||||||
|
// if the combobox is empty, use as bitmap size of the image list
|
||||||
|
// the size of the first valid image loaded
|
||||||
|
if (foundSize == wxDefaultSize)
|
||||||
|
foundSize = bmp.GetSize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -894,7 +904,8 @@ wxBitmap BitmapComboBoxWidgetsPage::QueryBitmap(wxString* pStr)
|
|||||||
bitmap = LoadBitmap(filepath);
|
bitmap = LoadBitmap(filepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxLogDebug(wxT("%i, %i"),bitmap.GetWidth(), bitmap.GetHeight());
|
if (bitmap.IsOk())
|
||||||
|
wxLogDebug(wxT("%i, %i"),bitmap.GetWidth(), bitmap.GetHeight());
|
||||||
|
|
||||||
::wxSetCursor( *wxSTANDARD_CURSOR );
|
::wxSetCursor( *wxSTANDARD_CURSOR );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user