forked from mirror/OpenTTD
Fix: TextfileWindow called virtual methods before constructor completed. (#11889)
SetStringParameters() was called during widget tree init in the constructor. Calls within a constructor cannot call the derived classes methods. This would result in invalid data being passed to the string system, which could then crash.
This commit is contained in:
@@ -82,13 +82,19 @@ static WindowDesc _textfile_desc(__FILE__, __LINE__,
|
||||
);
|
||||
|
||||
TextfileWindow::TextfileWindow(TextfileType file_type) : Window(&_textfile_desc), file_type(file_type)
|
||||
{
|
||||
/* Init of nested tree is deferred.
|
||||
* TextfileWindow::ConstructWindow must be called by the inheriting window. */
|
||||
}
|
||||
|
||||
void TextfileWindow::ConstructWindow()
|
||||
{
|
||||
this->CreateNestedTree();
|
||||
this->vscroll = this->GetScrollbar(WID_TF_VSCROLLBAR);
|
||||
this->hscroll = this->GetScrollbar(WID_TF_HSCROLLBAR);
|
||||
this->GetWidget<NWidgetCore>(WID_TF_CAPTION)->SetDataTip(STR_TEXTFILE_README_CAPTION + file_type, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS);
|
||||
this->GetWidget<NWidgetCore>(WID_TF_CAPTION)->SetDataTip(STR_TEXTFILE_README_CAPTION + this->file_type, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS);
|
||||
this->GetWidget<NWidgetStacked>(WID_TF_SEL_JUMPLIST)->SetDisplayedPlane(SZSP_HORIZONTAL);
|
||||
this->FinishInitNested(file_type);
|
||||
this->FinishInitNested(this->file_type);
|
||||
|
||||
this->DisableWidget(WID_TF_NAVBACK);
|
||||
this->DisableWidget(WID_TF_NAVFORWARD);
|
||||
|
Reference in New Issue
Block a user