Add some missing member variable initializations

These were all found by cppcheck. Even in constructors that are there "only
because of std containers" the class should be initialized correctly. You can
never know whether such an object does not get used, and then a nice crash
caused by dereferencing a NULL-pointer is better than undefined behaviour.
This commit is contained in:
Georg Baum 2015-09-13 19:47:21 +02:00
parent c09663d2cb
commit 699a6db9fa
15 changed files with 18 additions and 22 deletions

View File

@ -126,7 +126,8 @@ public:
/// Represent any of the above packages
static int const any;
///
Encoding() : fixedwidth_(true), unsafe_(false), complete_(false) {}
Encoding() : fixedwidth_(true), unsafe_(false), start_encodable_(0),
package_(none), complete_(false) {}
///
Encoding(std::string const & n, std::string const & l,
std::string const & g, std::string const & i,

View File

@ -334,6 +334,7 @@ void LyXRC::setDefaults()
full_screen_toolbars = true;
full_screen_tabbar = true;
full_screen_menubar = true;
full_screen_statusbar = true;
full_screen_scrollbar = true;
full_screen_width = 700;

View File

@ -142,14 +142,6 @@ public:
* are checked.
*/
std::string quoted_options_check(std::string const & str) const;
/**
* Flag indicating whether user made some input into PDF preferences.
* We want to save options, when user decide to switch off PDF support
* for a while.
*/
bool store_options;
};
} // namespace lyx

View File

@ -35,7 +35,7 @@ class TextMetrics
{
public:
/// Default constructor (only here for STL containers).
TextMetrics() : text_(0) {}
TextMetrics() : bv_(0), text_(0), main_text_(false), max_width_(0) {}
/// The only useful constructor.
TextMetrics(BufferView *, Text *);
@ -178,7 +178,7 @@ public:
\param x,y are absolute screen coordinates.
\param assert_in_view if true the cursor will be set on a row
that is completely visible
\param up whether we are going up or down (only used when
\param up whether we are going up or down (only used when
assert_in_view is true
\retval inset is non-null if the cursor is positionned inside
*/

View File

@ -38,7 +38,7 @@ class TocItem
public:
/// Default constructor for STL containers.
TocItem() : dit_(0) {}
TocItem() : dit_(0), depth_(0), output_(false) {}
///
TocItem(DocIterator const & dit,
int depth,

View File

@ -35,7 +35,7 @@ public:
NOLOCKING,
};
VCS(Buffer * b) : owner_(b) {}
VCS(Buffer * b) : vcstatus(NOLOCKING), owner_(b) {}
virtual ~VCS() {}
/// register a file for version control

View File

@ -106,6 +106,7 @@ public:
struct LayoutBox::Private
{
Private(LayoutBox * parent, GuiView & gv) : p(parent), owner_(gv),
inset_(0),
// set the layout model with two columns
// 1st: translated layout names
// 2nd: raw layout names

View File

@ -81,7 +81,7 @@ public:
TocModel::TocModel(QObject * parent)
: model_(new TocTypeModel(parent)),
sorted_model_(new QSortFilterProxyModel(parent)),
is_sorted_(false), maxdepth_(0), mindepth_(0)
is_sorted_(false), toc_(0), maxdepth_(0), mindepth_(0)
{
sorted_model_->setSortLocaleAware(true);
sorted_model_->setSourceModel(model_);

View File

@ -131,7 +131,7 @@ public:
};
///
InsetIPAChar() : Inset(0) {}
InsetIPAChar() : Inset(0), kind_(TONE_FALLING) {}
///
explicit InsetIPAChar(Kind k);
///

View File

@ -45,7 +45,7 @@ using frontend::Painter;
InsetLine::InsetLine(Buffer * buf, InsetCommandParams const & p)
: InsetCommand(buf, p)
: InsetCommand(buf, p), height_(0), offset_(0)
{}

View File

@ -53,7 +53,7 @@ public:
};
///
InsetSpecialChar() : Inset(0) {}
InsetSpecialChar() : Inset(0), kind_(HYPHENATION) {}
///
explicit InsetSpecialChar(Kind k);
///

View File

@ -652,7 +652,7 @@ Tabular::ColumnData::ColumnData()
Tabular::ltType::ltType()
: topDL(false),
: set(false), topDL(false),
bottomDL(false),
empty(false)
{}

View File

@ -29,14 +29,14 @@ using namespace lyx::support;
namespace lyx {
InsetMathColor::InsetMathColor(Buffer * buf, bool oldstyle, ColorCode color)
: InsetMathNest(buf, 1), oldstyle_(oldstyle),
: InsetMathNest(buf, 1), w_(0), oldstyle_(oldstyle),
color_(from_utf8(lcolor.getLaTeXName(color)))
{}
InsetMathColor::InsetMathColor(Buffer * buf, bool oldstyle,
docstring const & color)
: InsetMathNest(buf, 1), oldstyle_(oldstyle), color_(color)
: InsetMathNest(buf, 1), w_(0), oldstyle_(oldstyle), color_(color)
{}

View File

@ -37,7 +37,7 @@ namespace lyx {
InsetMathDecoration::InsetMathDecoration(Buffer * buf, latexkeys const * key)
: InsetMathNest(buf, 1), key_(key)
: InsetMathNest(buf, 1), key_(key), dh_(0), dy_(0), dw_(0)
{
// lyxerr << " creating deco " << key->name << endl;
}

View File

@ -142,7 +142,8 @@ inline void operator|=(Debug::Type & d1, Debug::Type d2)
class LyXErr
{
public:
LyXErr(): dt_(Debug::NONE), enabled_(true), second_enabled_(false) {}
LyXErr(): dt_(Debug::NONE), stream_(0), enabled_(true),
second_stream_(0), second_enabled_(false) {}
/// Disable the stream completely
void disable();