Remove unnecessary Realize() when constructing Visual Tools toolbar

The Realize() will change the toolbar size on macOS, which may trigger VideoDisplay::Render and VisualToolDrag::UpdateToggleButtons. Therefore, if we want to call Realize, it must be after setting VideoDisplay::tool and calling VisualTool::SetToolbar. Otherwise, the first will cause an infinite recursion from if(!tool) condition in VideoDisplay::Render, the latter will cause NULL dereference (because VisualToolDrag::toolbar is not set yet).

On the other hand, we do not need to call Realize here at all. If the toolbar does not show, we don't need to call Realize. If the toolbar will show, then Realize will be called by VisualTool after adding their buttons, in VisualTool::SetToolbar.

So we remove the Realize() call from VideoDisplay::SetTool.

Fix wangqr/Aegisub#21
Fix wangqr/Aegisub#44
This commit is contained in:
wangqr 2020-05-06 20:13:04 -04:00
parent ac88eadd78
commit 76802c3441
1 changed files with 0 additions and 1 deletions

View File

@ -430,7 +430,6 @@ void VideoDisplay::SetTool(std::unique_ptr<VisualToolBase> new_tool) {
toolBar->Show(false);
toolBar->ClearTools();
toolBar->AddSeparator();
toolBar->Realize();
tool->SetToolbar(toolBar);
// Update size as the new typesetting tool may have changed the subtoolbar size