Small fixes for the Q*Ref deprecation stuff

- don't force the deprecation sentence into a separate memory location
  (gives the compiler more leeway in how to lay stuff out)
- split the switch (will be useful when extending)
- fix a spelling mistake in one of the messages

Change-Id: Ied137dc8eee7047177983660e1a6776a0bf46bde
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Marc Mutz 2020-05-12 22:04:16 +02:00
parent 09ee4282e5
commit d68f3a81c9

View File

@ -5097,20 +5097,28 @@ namespace QtPrivate {
namespace DeprecatedRefClassBehavior { namespace DeprecatedRefClassBehavior {
void warn(WarningType w, EmittingClass c) void warn(WarningType w, EmittingClass c)
{ {
static const char deprecatedBehaviorString[] = const char *deprecatedBehaviorString =
"The corresponding behavior is deprecated, and will be changed" "The corresponding behavior is deprecated, and will be changed"
" in a future version of Qt."; " in a future version of Qt.";
const char *emittingClassName = nullptr; const char *emittingClassName = nullptr;
const char *containerClassName = nullptr;
switch (c) { switch (c) {
case EmittingClass::QByteRef: case EmittingClass::QByteRef:
emittingClassName = "QByteRef"; emittingClassName = "QByteRef";
containerClassName = "QByteArray";
break; break;
case EmittingClass::QCharRef: case EmittingClass::QCharRef:
emittingClassName = "QCharRef"; emittingClassName = "QCharRef";
break;
}
const char *containerClassName = nullptr;
switch (c) {
case EmittingClass::QByteRef:
containerClassName = "QByteArray";
break;
case EmittingClass::QCharRef:
containerClassName = "QString"; containerClassName = "QString";
break; break;
} }
@ -5121,7 +5129,7 @@ void warn(WarningType w, EmittingClass c)
emittingClassName, containerClassName, deprecatedBehaviorString); emittingClassName, containerClassName, deprecatedBehaviorString);
break; break;
case WarningType::DelayedDetach: case WarningType::DelayedDetach:
qWarning("Using %s with on a %s that is not already detached. %s", qWarning("Using %s on a %s that is not already detached. %s",
emittingClassName, containerClassName, deprecatedBehaviorString); emittingClassName, containerClassName, deprecatedBehaviorString);
break; break;
} }