1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-15 16:17:41 +02:00

Bug 2040 - Linux: Assert on recording or generating when main Window minimised

This commit is contained in:
James Crook 2018-12-02 14:45:40 +00:00
parent 90ea354002
commit 5a87d5ea67
3 changed files with 20 additions and 12 deletions

View File

@ -962,6 +962,7 @@ BEGIN_EVENT_TABLE(AudacityProject, wxFrame)
EVT_CLOSE(AudacityProject::OnCloseWindow)
EVT_SIZE(AudacityProject::OnSize)
EVT_SHOW(AudacityProject::OnShow)
EVT_ICONIZE(AudacityProject::OnIconize)
EVT_MOVE(AudacityProject::OnMove)
EVT_ACTIVATE(AudacityProject::OnActivate)
EVT_COMMAND_SCROLL_LINEUP(HSBarID, AudacityProject::OnScrollLeftButton)
@ -2202,14 +2203,25 @@ void AudacityProject::OnIconize(wxIconizeEvent &event)
unsigned int i;
// VisibileProjectCount seems to be just a counter for debugging.
// It's not used outside this function.
for(i=0;i<gAudacityProjects.size();i++){
if(gAudacityProjects[i]){
if( !gAudacityProjects[i]->mIconized )
VisibleProjectCount++;
}
}
event.Skip();
// This step is to fix part of Bug 2040, where the BackingPanel
// size was not restored after we leave Iconized state.
// Queue up a resize event using OnShow so that we
// refresh the track panel. But skip this, if we're iconized.
if( mIconized )
return;
wxShowEvent Evt;
OnShow( Evt );
}
void AudacityProject::OnMove(wxMoveEvent & event)

View File

@ -47,13 +47,13 @@ wxDC &BackedPanel::GetBackingDCForRepaint()
void BackedPanel::ResizeBacking()
{
// Delete the backing bitmap
if (mBacking)
mBackingDC.SelectObject(wxNullBitmap);
wxSize sz = GetClientSize();
mBacking = std::make_unique<wxBitmap>();
mBacking->Create(sz.x, sz.y,24); //, *dc);
// Bug 2040 - Avoid 0 x 0 bitmap when minimized.
mBacking->Create(std::max(sz.x,1), std::max(sz.y,1),24); //, *dc);
mBackingDC.SelectObject(*mBacking);
}
@ -64,14 +64,15 @@ void BackedPanel::RepairBitmap(wxDC &dc, wxCoord x, wxCoord y, wxCoord width, wx
void BackedPanel::DisplayBitmap(wxDC &dc)
{
if( mBacking )
RepairBitmap(dc, 0, 0, mBacking->GetWidth(), mBacking->GetHeight());
}
void BackedPanel::OnSize(wxSizeEvent & /* event */)
void BackedPanel::OnSize(wxSizeEvent & event)
{
// Tell OnPaint() to recreate the backing bitmap
mResizeBacking = true;
event.Skip();
// Refresh the entire area. Really only need to refresh when
// expanding...is it worth the trouble?
Refresh();

View File

@ -15,7 +15,7 @@
/// \brief BackedPanel is for a panel that consists of a bitmap with something drawn
/// obver it. It supports efficient repainting when the overlays change and
/// over it. It supports efficient repainting when the overlays change and
/// recreation of the bitmap when the panel size is changed.
class AUDACITY_DLL_API BackedPanel /* not final */ : public wxPanelWrapper {
public:
@ -27,15 +27,10 @@ public:
~BackedPanel();
wxDC &GetBackingDC();
wxDC &GetBackingDCForRepaint();
void ResizeBacking();
void RepairBitmap(wxDC &dc, wxCoord x, wxCoord y, wxCoord width, wxCoord height);
void DisplayBitmap(wxDC &dc);
void OnSize(wxSizeEvent & event);
private: