diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2018-04-20 18:58:28 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2018-04-20 22:05:46 +0000 |
commit | 17ae9305afb0c7f12bc8108bb12cf2f213272173 (patch) | |
tree | 2a8de373b5cf1f80668ee07212574e7c45c7bfc0 | |
parent | 100ebf1c97dec1fcfea29d790c07993d071cbb3f (diff) |
q{cocoa,ppd}printdevice: Fix string comparison
'QPrint::Color' should be returned in case 'ColorModel'
is NOT set to 'Gray'. However, the logic was inverted
before, since 'qstrcmp()' returns 0 if the two strings
match.
Also, eliminate a redundant condition:
The left-hand side of the '||' already makes sure that
'colorModel' is non-null, so there's no need to check again.
(Corresponding cppcheck warning: "Redundant condition: colorModel.
'!A || (A && B)' is equivalent to '!A || B'")
Change-Id: I965c29e8c020bc9c47a53678e23d94f05be3fd53
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaprintdevice.mm | 2 | ||||
-rw-r--r-- | src/plugins/printsupport/cups/qppdprintdevice.cpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaprintdevice.mm b/src/plugins/platforms/cocoa/qcocoaprintdevice.mm index f21dfd7205..d1beb5f9ea 100644 --- a/src/plugins/platforms/cocoa/qcocoaprintdevice.mm +++ b/src/plugins/platforms/cocoa/qcocoaprintdevice.mm @@ -411,7 +411,7 @@ QPrint::ColorMode QCocoaPrintDevice::defaultColorMode() const ppd_option_t *colorModel = ppdFindOption(m_ppd, "DefaultColorModel"); if (!colorModel) colorModel = ppdFindOption(m_ppd, "ColorModel"); - if (!colorModel || (colorModel && !qstrcmp(colorModel->defchoice, "Gray"))) + if (!colorModel || qstrcmp(colorModel->defchoice, "Gray") != 0) return QPrint::Color; } return QPrint::GrayScale; diff --git a/src/plugins/printsupport/cups/qppdprintdevice.cpp b/src/plugins/printsupport/cups/qppdprintdevice.cpp index 454bc89bfe..d2ddc4144f 100644 --- a/src/plugins/printsupport/cups/qppdprintdevice.cpp +++ b/src/plugins/printsupport/cups/qppdprintdevice.cpp @@ -427,7 +427,7 @@ QPrint::ColorMode QPpdPrintDevice::defaultColorMode() const ppd_option_t *colorModel = ppdFindOption(m_ppd, "DefaultColorModel"); if (!colorModel) colorModel = ppdFindOption(m_ppd, "ColorModel"); - if (!colorModel || (colorModel && !qstrcmp(colorModel->defchoice, "Gray"))) + if (!colorModel || qstrcmp(colorModel->defchoice, "Gray") != 0) return QPrint::Color; } return QPrint::GrayScale; |