Avoid narrowing in array initializator

Gcc 4.7 warns that this kind of narrowing is illegal in C++11, so
we can just as well fix that right now.

In GuiFontMetrics this is fixed by chaning the types in the AscendDescend struct
from short int to int.
In ParagraphMetrics it is fixed by addint explicit casts.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40586 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2012-01-07 18:29:07 +00:00
parent dfffb9a6d1
commit d2f2148c90
2 changed files with 5 additions and 4 deletions

View File

@ -93,14 +93,15 @@ size_t ParagraphMetrics::computeRowSignature(Row const & row,
crc.process_bytes(b, sizeof(char_type));
if (bparams.trackChanges) {
Change change = par_->lookupChange(i);
char_type const b[] = { change.type };
char_type const b[] = { static_cast<char_type>(change.type) };
// 1 byte is enough to encode Change::Type
crc.process_bytes(b, 1);
}
}
Dimension const & d = row.dimension();
char_type const b[] = { row.sel_beg, row.sel_end,
char_type const b[] = { static_cast<char_type>(row.sel_beg),
static_cast<char_type>(row.sel_end),
row.begin_margin_sel, row.end_margin_sel, d.wid, d.asc, d.des};
crc.process_bytes(b, sizeof(b));

View File

@ -66,8 +66,8 @@ private:
mutable QHash<char_type, int> width_cache_;
struct AscendDescend {
short int ascent;
short int descent;
int ascent;
int descent;
};
/// Cache of char ascends and descends
mutable QHash<char_type, AscendDescend> metrics_cache_;