PVS: V629 Consider inspecting the 'col.red() << 24' expression. Bit shifting of the 32-bit value with a subsequent expansion to the 64-bit type.

This commit is contained in:
wmayer
2019-02-17 22:27:00 +01:00
parent 2bb5797568
commit f0320d954a
5 changed files with 71 additions and 59 deletions

View File

@@ -429,12 +429,14 @@ void PrefColorButton::restorePreferences()
QColor col = color();
unsigned long lcol = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8);
unsigned int icol = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8);
unsigned long lcol = static_cast<unsigned long>(icol);
lcol = getWindowParameter()->GetUnsigned( entryName(), lcol );
int r = (lcol >> 24)&0xff;
int g = (lcol >> 16)&0xff;
int b = (lcol >> 8)&0xff;
icol = static_cast<unsigned int>(lcol);
int r = (icol >> 24)&0xff;
int g = (icol >> 16)&0xff;
int b = (icol >> 8)&0xff;
setColor(QColor(r,g,b));
}
@@ -449,9 +451,8 @@ void PrefColorButton::savePreferences()
QColor col = color();
// (r,g,b,a) with a = 255 (opaque)
unsigned long lcol = (static_cast<unsigned long> (col.red()) << 24)
| (static_cast<unsigned long> (col.green()) << 16)
| (static_cast<unsigned long> (col.blue()) << 8) | 255;
unsigned int icol = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8) | 255;
unsigned long lcol = static_cast<unsigned long>(icol);
getWindowParameter()->SetUnsigned( entryName(), lcol );
}