fix MSVC warning found by /W4

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2022-12-06 16:06:13 +08:00
parent 1e429b363b
commit 64ef4b25ca
2 changed files with 18 additions and 11 deletions

View File

@ -96,16 +96,16 @@ Q_GLOBAL_STATIC(MicaMaterialData, g_micaMaterialData)
} }
#else // !FRAMELESSHELPER_CORE_NO_PRIVATE #else // !FRAMELESSHELPER_CORE_NO_PRIVATE
template<const int shift> template<const int shift>
[[nodiscard]] static inline int qt_static_shift(const int value) [[nodiscard]] static inline constexpr int qt_static_shift(const int value)
{ {
if (shift == 0) { if constexpr (shift == 0) {
return value; return value;
} } else if constexpr (shift > 0) {
if (shift > 0) {
return (value << (quint32(shift) & 0x1f)); return (value << (quint32(shift) & 0x1f));
} } else {
return (value >> (quint32(-shift) & 0x1f)); return (value >> (quint32(-shift) & 0x1f));
} }
}
template<const int aprec, const int zprec> template<const int aprec, const int zprec>
static inline void qt_blurinner(uchar *bptr, int &zR, int &zG, int &zB, int &zA, const int alpha) static inline void qt_blurinner(uchar *bptr, int &zR, int &zG, int &zB, int &zA, const int alpha)
@ -155,9 +155,16 @@ static inline void qt_blurrow(QImage &im, const int line, const int alpha)
int zR = 0, zG = 0, zB = 0, zA = 0; int zR = 0, zG = 0, zB = 0, zA = 0;
#ifdef Q_CC_MSVC
# pragma warning(push)
# pragma warning(disable:4127) // false alarm.
#endif // Q_CC_MSVC
if (alphaOnly && (im.format() != QImage::Format_Indexed8)) { if (alphaOnly && (im.format() != QImage::Format_Indexed8)) {
bptr += alphaIndex; bptr += alphaIndex;
} }
#ifdef Q_CC_MSVC
# pragma warning(pop)
#endif // Q_CC_MSVC
const int stride = (im.depth() >> 3); const int stride = (im.depth() >> 3);
const int im_width = im.width(); const int im_width = im.width();

View File

@ -622,20 +622,20 @@ FramelessQuickHelper *FramelessQuickHelperPrivate::findOrCreateFramelessHelper(Q
} }
QObject *parent = nullptr; QObject *parent = nullptr;
QQuickItem *parentItem = nullptr; QQuickItem *parentItem = nullptr;
if (const auto window = qobject_cast<QQuickWindow *>(object)) { if (const auto objWindow = qobject_cast<QQuickWindow *>(object)) {
if (QQuickItem * const item = window->contentItem()) { if (QQuickItem * const item = objWindow->contentItem()) {
parent = item; parent = item;
parentItem = item; parentItem = item;
} else { } else {
parent = window; parent = objWindow;
} }
} else if (const auto item = qobject_cast<QQuickItem *>(object)) { } else if (const auto item = qobject_cast<QQuickItem *>(object)) {
if (QQuickWindow * const window = item->window()) { if (QQuickWindow * const itemWindow = item->window()) {
if (QQuickItem * const contentItem = window->contentItem()) { if (QQuickItem * const contentItem = itemWindow->contentItem()) {
parent = contentItem; parent = contentItem;
parentItem = contentItem; parentItem = contentItem;
} else { } else {
parent = window; parent = itemWindow;
parentItem = item; parentItem = item;
} }
} else { } else {