From 7efaed4de44347f940dfd06ea20d0291b19f54ef Mon Sep 17 00:00:00 2001 From: Mattia Barbon Date: Thu, 28 Mar 2002 20:51:55 +0000 Subject: [PATCH] Fixed problems with wxFrame::SetIcons git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14847 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/iconbndl.cpp | 4 +++- src/gtk/toplevel.cpp | 15 ++++++++------- src/gtk1/toplevel.cpp | 15 ++++++++------- src/unix/utilsx11.cpp | 3 ++- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/common/iconbndl.cpp b/src/common/iconbndl.cpp index 479c5dd27c..ef64f80fae 100644 --- a/src/common/iconbndl.cpp +++ b/src/common/iconbndl.cpp @@ -83,6 +83,8 @@ const wxIcon& wxIconBundle::GetIcon( const wxSize& size ) const for( i = 0; i < max; ++i ) { + if( !m_icons[i].Ok() ) + continue; wxCoord sx = m_icons[i].GetWidth(), sy = m_icons[i].GetHeight(); // requested size if( sx == size.x && sy == size.y ) @@ -105,7 +107,7 @@ void wxIconBundle::AddIcon( const wxIcon& icon ) for( i = 0; i < max; ++i ) { wxIcon& tmp = m_icons[i]; - if( tmp.GetWidth() == icon.GetWidth() && + if( tmp.Ok() && tmp.GetWidth() == icon.GetWidth() && tmp.GetHeight() == icon.GetHeight() ) { tmp = icon; diff --git a/src/gtk/toplevel.cpp b/src/gtk/toplevel.cpp index 6484fa7f00..f94dbeab59 100644 --- a/src/gtk/toplevel.cpp +++ b/src/gtk/toplevel.cpp @@ -191,12 +191,13 @@ gtk_frame_realized_callback( GtkWidget * WXUNUSED(widget), wxTopLevelWindowGTK * gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1); // reset the icon - wxIcon iconOld = win->GetIcon(); - if ( iconOld != wxNullIcon ) + wxIconBundle iconsOld = win->GetIcons(); + wxIcon tmp = iconsOld.GetIcon( -1 ); // operator != is not-const + if ( tmp != wxNullIcon ) { - wxIcon icon( iconOld ); + // wxIconBundle icon( iconOld ); win->SetIcon( wxNullIcon ); - win->SetIcon( icon ); + win->SetIcons( iconsOld ); } // we set the focus to the child that accepts the focus. this @@ -840,13 +841,13 @@ void wxTopLevelWindowGTK::SetIcons( const wxIconBundle &icons ) { wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); GdkWindow* window = m_widget->window; - wxCHECK_RET( window, _T("window not created yet - can't set icon") ); wxTopLevelWindowBase::SetIcons( icons ); DoSetIcon( icons.GetIcon( -1 ) ); - wxSetIconsX11( (WXDisplay*)GDK_WINDOW_XDISPLAY( window ), - (WXWindow)GDK_WINDOW_XWINDOW( window ), icons ); + if( window ) + wxSetIconsX11( (WXDisplay*)GDK_WINDOW_XDISPLAY( window ), + (WXWindow)GDK_WINDOW_XWINDOW( window ), icons ); } // ---------------------------------------------------------------------------- diff --git a/src/gtk1/toplevel.cpp b/src/gtk1/toplevel.cpp index 6484fa7f00..f94dbeab59 100644 --- a/src/gtk1/toplevel.cpp +++ b/src/gtk1/toplevel.cpp @@ -191,12 +191,13 @@ gtk_frame_realized_callback( GtkWidget * WXUNUSED(widget), wxTopLevelWindowGTK * gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1); // reset the icon - wxIcon iconOld = win->GetIcon(); - if ( iconOld != wxNullIcon ) + wxIconBundle iconsOld = win->GetIcons(); + wxIcon tmp = iconsOld.GetIcon( -1 ); // operator != is not-const + if ( tmp != wxNullIcon ) { - wxIcon icon( iconOld ); + // wxIconBundle icon( iconOld ); win->SetIcon( wxNullIcon ); - win->SetIcon( icon ); + win->SetIcons( iconsOld ); } // we set the focus to the child that accepts the focus. this @@ -840,13 +841,13 @@ void wxTopLevelWindowGTK::SetIcons( const wxIconBundle &icons ) { wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); GdkWindow* window = m_widget->window; - wxCHECK_RET( window, _T("window not created yet - can't set icon") ); wxTopLevelWindowBase::SetIcons( icons ); DoSetIcon( icons.GetIcon( -1 ) ); - wxSetIconsX11( (WXDisplay*)GDK_WINDOW_XDISPLAY( window ), - (WXWindow)GDK_WINDOW_XWINDOW( window ), icons ); + if( window ) + wxSetIconsX11( (WXDisplay*)GDK_WINDOW_XDISPLAY( window ), + (WXWindow)GDK_WINDOW_XWINDOW( window ), icons ); } // ---------------------------------------------------------------------------- diff --git a/src/unix/utilsx11.cpp b/src/unix/utilsx11.cpp index 778447cea1..d09ae24992 100644 --- a/src/unix/utilsx11.cpp +++ b/src/unix/utilsx11.cpp @@ -32,7 +32,8 @@ void wxSetIconsX11( WXDisplay* display, WXWindow window, size_t i, max = ib.m_icons.GetCount(); for( i = 0; i < max; ++i ) - size += 2 + ib.m_icons[i].GetWidth() * ib.m_icons[i].GetHeight(); + if( ib.m_icons[i].Ok() ) + size += 2 + ib.m_icons[i].GetWidth() * ib.m_icons[i].GetHeight(); Atom net_wm_icon = XInternAtom( (Display*)display, "_NET_WM_ICON", 0 );