Avoid conditional branching on uninitialized values

C++ initializes members in the order in which they are defined in class. So the
order is important if the members are accessed by other initializers or methods
called from them.

Class BoxLayerWidget:
  _roundRect is initialized based on _layerType through the st() method.

Class Checkbox:
  Arguments of _text constructor depend on _checkAlignment through the
  countTextMinWidth and the checkRect methods.
This commit is contained in:
Nicholas Guriev 2022-04-08 18:35:32 +03:00 committed by John Preston
parent e5d8e54035
commit 258cacf7c5
2 changed files with 2 additions and 2 deletions

View file

@ -128,6 +128,7 @@ private:
const style::Box *_st = nullptr;
not_null<LayerStackWidget*> _layer;
bool _layerType = false;
int _fullHeight = 0;
bool _noContentMargin = false;
@ -140,7 +141,6 @@ private:
rpl::variable<QString> _additionalTitle;
int _titleLeft = 0;
int _titleTop = 0;
bool _layerType = false;
bool _closeByOutsideClick = true;
std::vector<object_ptr<RoundButton>> _buttons;

View file

@ -228,8 +228,8 @@ private:
rpl::event_stream<bool> _checkedChanges;
QPixmap _checkCache;
Text::String _text;
style::align _checkAlignment = style::al_left;
Text::String _text;
int _allowTextLines = 1;
bool _textBreakEverywhere = false;