Fix potential null pointer detected by Coverity

This commit is contained in:
Juergen Spitzmueller 2018-09-01 10:45:03 +02:00
parent 5279f3e11f
commit bc644d131c

View File

@ -182,11 +182,14 @@ docstring InsetInfoParams::getDate(string const iname, QDate const date) const
else if (iname == "ISO") else if (iname == "ISO")
return qstring_to_ucs4(date.toString(Qt::ISODate)); return qstring_to_ucs4(date.toString(Qt::ISODate));
else if (iname == "loclong") else if (iname == "loclong")
return qstring_to_ucs4(loc.toString(date, toqstr(lang->dateFormat(0)))); return lang ? qstring_to_ucs4(loc.toString(date, toqstr(lang->dateFormat(0))))
: _("No long date format (language unknown)!");
else if (iname == "locmedium") else if (iname == "locmedium")
return qstring_to_ucs4(loc.toString(date, toqstr(lang->dateFormat(1)))); return lang ? qstring_to_ucs4(loc.toString(date, toqstr(lang->dateFormat(1))))
: _("No medium date format (language unknown)!");
else if (iname == "locshort") else if (iname == "locshort")
return qstring_to_ucs4(loc.toString(date, toqstr(lang->dateFormat(2)))); return lang ? qstring_to_ucs4(loc.toString(date, toqstr(lang->dateFormat(2))))
: _("No short date format (language unknown)!");
else else
return qstring_to_ucs4(loc.toString(date, toqstr(iname))); return qstring_to_ucs4(loc.toString(date, toqstr(iname)));
} }