diff --git a/xvaga/xvaga.cpp b/xvaga/xvaga.cpp index 0c6936bc2..fcb051ad6 100755 --- a/xvaga/xvaga.cpp +++ b/xvaga/xvaga.cpp @@ -2511,17 +2511,21 @@ XVT_FNTID xvt_res_get_font(int rid) XVT_IMAGE xvt_res_get_icon(int rid) { + XVT_IMAGE img = NULL; const wxIcon icon = xvtart_GetIconResource(rid); - int w = icon.GetWidth(); if (w <= 0) w = 32; - int h = icon.GetHeight(); if (h <= 0) h = 32; - wxBitmap bmp(w, h, icon.GetDepth()); + if (icon.IsOk()) { - wxMemoryDC dc(bmp); - dc.DrawIcon(icon, 0, 0); + int w = icon.GetWidth(); if (w <= 0) w = 32; + int h = icon.GetHeight(); if (h <= 0) h = 32; + wxBitmap bmp(w, h, icon.GetDepth()); + { + wxMemoryDC dc(bmp); + dc.DrawIcon(icon, 0, 0); + } + XVT_IMAGE_FORMAT xif = bmp.GetDepth()>8 ? XVT_IMAGE_RGB : XVT_IMAGE_CL8; + img = xvt_image_create(xif, w, h, 0); + ((TXVT_IMAGE*)img)->Image() = bmp.ConvertToImage(); } - XVT_IMAGE_FORMAT xif = bmp.GetDepth()>8 ? XVT_IMAGE_RGB : XVT_IMAGE_CL8; - XVT_IMAGE img = xvt_image_create(xif, w, h, 0); - ((TXVT_IMAGE*)img)->Image() = bmp.ConvertToImage(); return img; } diff --git a/xvaga/xvtart.cpp b/xvaga/xvtart.cpp index ea4f865c7..cd92d771c 100755 --- a/xvaga/xvtart.cpp +++ b/xvaga/xvtart.cpp @@ -292,7 +292,7 @@ wxIcon TArtProvider::GetIcon(const wxArtID& id, const wxArtClient& client, const wxIconBundle bundle = GetIconBundle(id, client); const wxSize sz = size == wxDefaultSize ? GetNativeSizeHint(client) : size; wxIcon ico = bundle.GetIcon(sz); - if (sz.x != ico.GetWidth()) // Should never happen :-) + if (ico.IsOk() && sz.x != ico.GetWidth()) // Should never happen :-) { wxBitmap bmpbig(bundle.GetIcon()); wxImage img = bmpbig.ConvertToImage(); diff --git a/xvaga/xvtctl.cpp b/xvaga/xvtctl.cpp index 68628f90c..d1c334be0 100755 --- a/xvaga/xvtctl.cpp +++ b/xvaga/xvtctl.cpp @@ -1552,9 +1552,14 @@ void TwxOutlookBar::OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const { const int sz = nSide > 16 ? (nSide < 48 ? (nSide/16*16) : 48) : 16; const wxIcon ico = xvtart_GetIconResource(oi.m_nIconId, wxART_TOOLBAR, sz); - const wxSize szIco(ico.GetWidth(), ico.GetHeight()); - dc.DrawIcon(ico, rect.x+nTextOffset, rect.y+(nSide-szIco.y)/2); - nTextOffset += nTextOffset+szIco.x; + if (ico.IsOk()) + { + const wxSize szIco(ico.GetWidth(), ico.GetHeight()); + dc.DrawIcon(ico, rect.x+nTextOffset, rect.y+(nSide-szIco.y)/2); + nTextOffset += nTextOffset+szIco.x; + } + else + nTextOffset += nTextOffset+sz; } dc.SetFont(GetFont()); // Imposta il font predefinito per questo controllo