We’re seeing an issue with Window::Freeze and Window::Thaw in wxWidgets 3.1.4 on CentOS 8.3. The gtk version is 3.22.30; I can provide other versions if needed.
The following “hello world” application demonstrates the issue:
Code: Select all
// wxWidgets "Hello world" Program
// For compilers that support precompilation, includes "wx/wx.h".
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
class MyApp: public wxApp
{
public:
virtual bool OnInit();
};
class MyFrame: public wxFrame
{
public:
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
private:
void OnHello(wxCommandEvent& event);
void OnExit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
wxDECLARE_EVENT_TABLE();
};
enum
{
ID_Hello = 1
};
wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(ID_Hello, MyFrame::OnHello)
EVT_MENU(wxID_EXIT, MyFrame::OnExit)
EVT_MENU(wxID_ABOUT, MyFrame::OnAbout)
wxEND_EVENT_TABLE()
wxIMPLEMENT_APP(MyApp);
bool MyApp::OnInit()
{
MyFrame *frame = new MyFrame( "Hello World", wxPoint(50, 50), wxSize(450, 340) );
frame->Show( true );
return true;
}
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame(NULL, wxID_ANY, title, pos, size)
{
wxMenu *menuFile = new wxMenu;
menuFile->Append(ID_Hello, "&Hello...\tCtrl-H",
"Help string shown in status bar for this menu item");
menuFile->AppendSeparator();
menuFile->Append(wxID_EXIT);
wxMenu *menuHelp = new wxMenu;
menuHelp->Append(wxID_ABOUT);
wxMenuBar *menuBar = new wxMenuBar;
menuBar->Append( menuFile, "&File" );
menuBar->Append( menuHelp, "&Help" );
SetMenuBar( menuBar );
CreateStatusBar();
SetStatusText( "Welcome to wxWidgets!" );
}
void MyFrame::OnExit(wxCommandEvent& event)
{
Close( true );
}
void MyFrame::OnAbout(wxCommandEvent& event)
{
// Freeze used here. The update to the status bar below is not expected to display until after the
// message box is dismissed.
this->Freeze();
SetStatusText( "New text!" );
wxMessageBox( "This is a wxWidgets' Hello world sample",
"About Hello World", wxOK | wxICON_INFORMATION );
this->Thaw();
}
void MyFrame::OnHello(wxCommandEvent& event)
{
wxLogMessage("Hello world from wxWidgets!");
}
In older versions of wxWidgets (for example, 3.0.0), freezing a window doesn’t cause it to turn black as shown above. For example, in 3.0.0, we see the following after clicking Help > About:
This is the behavior I expect (though I’m not sure this exact behavior is specified). We lean on this mechanism quite heavily to make updates to child windows but hold off on displaying them until I call Thaw(), just like MyFrame::OnAbout in the example code.
For both versions, after “OK” is clicked, the main/background window is redrawn and "New text!" shows up in the status bar as expected.
We also get the expected behavior (what's shown in 3.0.0-frozen.png) when using wxWidgets 3.1.4 with GTK2 instead of GTK3.
For reference, it looks like there have been at least a few updates to the freeze/thaw code for GTK since 3.0.0, though I’m not familiar enough with GTK to fully understand them. For example:
- Avoid using gdk_window_freeze_updates() to implement Freeze() (https://github.com/wxWidgets/wxWidgets/ ... 774284e1a6)
- Avoid freeze count mismatches with GTK 2.18+ when impl_window changes ... (https://github.com/wxWidgets/wxWidgets/ ... 298e7ec683)
Is this behavior demonstrated in the first image expected behavior? If not, does anyone know what might be causing the window to turn black while it’s frozen?