Darrell Walisser
2017-02-24 17:29:10 UTC
I have been having this for while and assumed it was the oddity of my
system setup. I use LXDE with compositor disabled, on Ubuntu 16.04, which
is a bit unusual.
The assert (see trace below) happens frequently when starting audacity or
closing a project, but not always. It happens just before the project
window is shown, or in the process of being shown for the first time.
The first time time OverlayPanel::DrawOverlays is called, pDC is null, so
wxClientDC is created. However, dc.IsOk() will return true and yet
dc.GetHandle() will return null, leading to the assert fail shortly after. The
rest of the time, pDC is not null and there is no error.
Assuming the client dc is in fact not ready to do anything, I arrived at
the following patch. I'm not familiar enough with wxWidgets to know if this
is the best fix.
diff --git a/src/widgets/OverlayPanel.cpp b/src/widgets/OverlayPanel.cpp
index bbd5e2d..cbb7053 100644
--- a/src/widgets/OverlayPanel.cpp
+++ b/src/widgets/OverlayPanel.cpp
@@ -84,6 +84,10 @@ void OverlayPanel::DrawOverlays(bool repaint_all, wxDC
*pDC)
Maybe<wxClientDC> myDC;
auto &dc = pDC ? *pDC : (myDC.create(this), *myDC);
+ // Somehow this can be null, maybe just before project window is
realized
+ if (!dc.GetHandle())
+ return;
+
// Erase
bool done = true;
auto it2 = pairs.begin();
---
ASSERT INFO:
../src/gtk/dcclient.cpp(2043): assert "m_window" failed in DoGetSize():
GetSize() doesn't work without window
BACKTRACE:
[1] wxClientDCImpl::DoGetSize(int*, int*) const
[2] wxRect::wxRect(wxSize const&) /usr/include/wx-3.0/wx/gdicmn.h:710
[3] OverlayPanel::DrawOverlays(bool, wxDC*)
/home/ghaxt/sw/audacity/src/widgets/OverlayPanel.cpp:100
[4] TrackPanel::OnTimer(wxTimerEvent&)
/home/ghaxt/sw/audacity/src/TrackPanel.cpp:972
[5] wxAppConsoleBase::CallEventHandler(wxEvtHandler*, wxEventFunctor&,
wxEvent&) const
[6] wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&,
wxEvtHandler*, wxEvent&)
[7] wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*)
[8] wxEvtHandler::TryHereOnly(wxEvent&)
[9] wxEvtHandler::ProcessEventLocally(wxEvent&)
[10] wxEvtHandler::ProcessEvent(wxEvent&)
[11] wxEvtHandler::ProcessPendingEvents()
[12] wxAppConsoleBase::ProcessPendingEvents()
[13] wxApp::DoIdle()
[14] g_main_context_dispatch
[15] g_main_loop_run
[16] gtk_main
[17] wxGUIEventLoop::DoRun()
[18] wxEventLoopBase::Run()
[19] wxAppConsoleBase::MainLoop()
[20] wxEntry(int&, wchar_t**)
[21] main /home/ghaxt/sw/audacity/src/AudacityApp.cpp:726
[22] __libc_start_main
[23] _start
system setup. I use LXDE with compositor disabled, on Ubuntu 16.04, which
is a bit unusual.
The assert (see trace below) happens frequently when starting audacity or
closing a project, but not always. It happens just before the project
window is shown, or in the process of being shown for the first time.
The first time time OverlayPanel::DrawOverlays is called, pDC is null, so
wxClientDC is created. However, dc.IsOk() will return true and yet
dc.GetHandle() will return null, leading to the assert fail shortly after. The
rest of the time, pDC is not null and there is no error.
Assuming the client dc is in fact not ready to do anything, I arrived at
the following patch. I'm not familiar enough with wxWidgets to know if this
is the best fix.
diff --git a/src/widgets/OverlayPanel.cpp b/src/widgets/OverlayPanel.cpp
index bbd5e2d..cbb7053 100644
--- a/src/widgets/OverlayPanel.cpp
+++ b/src/widgets/OverlayPanel.cpp
@@ -84,6 +84,10 @@ void OverlayPanel::DrawOverlays(bool repaint_all, wxDC
*pDC)
Maybe<wxClientDC> myDC;
auto &dc = pDC ? *pDC : (myDC.create(this), *myDC);
+ // Somehow this can be null, maybe just before project window is
realized
+ if (!dc.GetHandle())
+ return;
+
// Erase
bool done = true;
auto it2 = pairs.begin();
---
ASSERT INFO:
../src/gtk/dcclient.cpp(2043): assert "m_window" failed in DoGetSize():
GetSize() doesn't work without window
BACKTRACE:
[1] wxClientDCImpl::DoGetSize(int*, int*) const
[2] wxRect::wxRect(wxSize const&) /usr/include/wx-3.0/wx/gdicmn.h:710
[3] OverlayPanel::DrawOverlays(bool, wxDC*)
/home/ghaxt/sw/audacity/src/widgets/OverlayPanel.cpp:100
[4] TrackPanel::OnTimer(wxTimerEvent&)
/home/ghaxt/sw/audacity/src/TrackPanel.cpp:972
[5] wxAppConsoleBase::CallEventHandler(wxEvtHandler*, wxEventFunctor&,
wxEvent&) const
[6] wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&,
wxEvtHandler*, wxEvent&)
[7] wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*)
[8] wxEvtHandler::TryHereOnly(wxEvent&)
[9] wxEvtHandler::ProcessEventLocally(wxEvent&)
[10] wxEvtHandler::ProcessEvent(wxEvent&)
[11] wxEvtHandler::ProcessPendingEvents()
[12] wxAppConsoleBase::ProcessPendingEvents()
[13] wxApp::DoIdle()
[14] g_main_context_dispatch
[15] g_main_loop_run
[16] gtk_main
[17] wxGUIEventLoop::DoRun()
[18] wxEventLoopBase::Run()
[19] wxAppConsoleBase::MainLoop()
[20] wxEntry(int&, wchar_t**)
[21] main /home/ghaxt/sw/audacity/src/AudacityApp.cpp:726
[22] __libc_start_main
[23] _start