vslavik / poedit

Translations editor for Mac, Windows and Unix
https://poedit.net
MIT License
1.71k stars 274 forks source link

Assertion error when opening code occurrence window with wxGTK 3.1.6 #745

Closed super7ramp closed 2 years ago

super7ramp commented 2 years ago

Environment

Bug

An assertion error is displayed when opening the code occurrence window:

ASSERT INFO:
./src/common/sizer.cpp(850): assert "CheckExpectedParentIs(w, m_containingWindow)" failed in DoInsert(): Windows managed by the sizer associated with the given window must have this window as parent, otherwise they will not be repositioned correctly.

Please use the window wxPanel@0x562774cfac00 ("panel") with which this sizer is associated, as the parent when creating the window wxStaticLine@0x56277525c140 ("staticLine") managed by it.

BACKTRACE:
[1] wxSizer::DoInsert(unsigned long, wxSizerItem*)
[2] wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&)
[3] wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*)
[4] wxEvtHandler::TryHereOnly(wxEvent&)
[5] wxEvtHandler::ProcessEventLocally(wxEvent&)
[6] wxEvtHandler::ProcessEvent(wxEvent&)
[7] wxWindowBase::TryAfter(wxEvent&)
[8] wxWindowBase::TryAfter(wxEvent&)
[9] wxWindowBase::TryAfter(wxEvent&)
[10] wxWindowBase::TryAfter(wxEvent&)
[11] wxEvtHandler::SafelyProcessEvent(wxEvent&)
[12] wxMenuBase::SendEvent(int, int)
[13] g_closure_invoke
[14] g_signal_emit_valist
[15] g_signal_emit
[16] gtk_widget_activate
[17] gtk_menu_shell_activate_item
[18] g_signal_emit_valist
[19] g_signal_emit
[20] gtk_main_do_event
[21] g_main_context_dispatch
[22] g_main_context_iteration
[23] gtk_main_iteration
[24] wxWindow::DoPopupMenu(wxMenu*, int, int)
[25] wxWindowBase::PopupMenu(wxMenu*, int, int)
[26] wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&)
[27] wxEvtHandler::SearchDynamicEventTable(wxEvent&)
[28] wxEvtHandler::TryHereOnly(wxEvent&)
[29] wxEvtHandler::ProcessEventLocally(wxEvent&)
[30] wxEvtHandler::ProcessEvent(wxEvent&)
[31] wxEvtHandler::SafelyProcessEvent(wxEvent&)
[32] g_closure_invoke
[33] g_signal_emit_valist
[34] g_signal_emit
[35] gtk_main_do_event
[36] g_main_context_dispatch
[37] g_main_loop_run
[38] gtk_main
[39] wxGUIEventLoop::DoRun()
[40] wxEventLoopBase::Run()
[41] wxAppConsoleBase::MainLoop()
[42] wxEntry(int&, wchar_t**)
[43] __libc_start_main

The following patch making "panel" the parent of "static line" as suggested by the assertion message makes the error disappear:

diff --git a/src/fileviewer.cpp b/src/fileviewer.cpp
index 63d5a1336..e8516e3f8 100644
--- a/src/fileviewer.cpp
+++ b/src/fileviewer.cpp
@@ -136,7 +136,7 @@ FileViewer::FileViewer(wxWindow*)
 #endif
     m_topBarSizer->Add(m_openInEditor, wxSizerFlags().Center().ReserveSpaceEvenIfHidden().Border(wxLEFT, PX(10)));

-    sizer->Add(new wxStaticLine(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1)), wxSizerFlags().Expand().Border(wxLEFT|wxRIGHT, PX(5)));
+    sizer->Add(new wxStaticLine(panel, wxID_ANY, wxDefaultPosition, wxSize(-1, 1)), wxSizerFlags().Expand().Border(wxLEFT|wxRIGHT, PX(5)));

     m_content = wxWebView::New(panel, wxID_ANY);
     sizer->Add(m_content, 1, wxEXPAND);

(Tested only on the environment mentioned above.)

Steps to reproduce

  1. Decompress and open this translation file: zypper-master-fr.po.gz.
  2. Right click on the first string > Select the entry under "Code Occurrences"
vslavik commented 2 years ago

Thanks a lot! I committed the fix (attributed to you) in 1a70ce711c685c3292e10e5812d31f11dc6d41ad.