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:
@@ -23,8 +23,6 @@ struct TextfileWindow : public Window, MissingGlyphSearcher {
|
||||
Scrollbar *vscroll; ///< Vertical scrollbar.
|
||||
Scrollbar *hscroll; ///< Horizontal scrollbar.
|
||||
|
||||
TextfileWindow(TextfileType file_type);
|
||||
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override;
|
||||
void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override;
|
||||
void DrawWidget(const Rect &r, WidgetID widget) const override;
|
||||
@@ -42,6 +40,9 @@ struct TextfileWindow : public Window, MissingGlyphSearcher {
|
||||
virtual void LoadTextfile(const std::string &textfile, Subdirectory dir);
|
||||
|
||||
protected:
|
||||
TextfileWindow(TextfileType file_type);
|
||||
void ConstructWindow();
|
||||
|
||||
struct Line {
|
||||
int top{0}; ///< Top scroll position in visual lines.
|
||||
int bottom{0}; ///< Bottom scroll position in visual lines.
|
||||
|
Reference in New Issue
Block a user