diff --git a/core/script/kjs_field.cpp b/core/script/kjs_field.cpp index 46af92080..31a89e5a8 100644 --- a/core/script/kjs_field.cpp +++ b/core/script/kjs_field.cpp @@ -120,17 +120,20 @@ static KJSObject fieldGetType(KJSContext *, void *object) } // Field.value (getter) -static KJSObject fieldGetValue(KJSContext * /*context*/, void *object) +static KJSObject fieldGetValue(KJSContext *context, void *object) { FormField *field = reinterpret_cast(object); + KJSObject result = KJSUndefined(); switch (field->type()) { case FormField::FormButton: { const FormFieldButton *button = static_cast(field); if (button->state()) { - return KJSString(QStringLiteral("Yes")); + result = KJSString(QStringLiteral("Yes")); + } else { + result = KJSString(QStringLiteral("Off")); } - return KJSString(QStringLiteral("Off")); + break; } case FormField::FormText: { const FormFieldText *text = static_cast(field); @@ -138,16 +141,17 @@ static KJSObject fieldGetValue(KJSContext * /*context*/, void *object) bool ok; const double textAsNumber = locale.toDouble(text->text(), &ok); if (ok) { - return KJSNumber(textAsNumber); + result = KJSNumber(textAsNumber); } else { - return KJSString(text->text()); + result = KJSString(text->text()); } + break; } case FormField::FormChoice: { const FormFieldChoice *choice = static_cast(field); const QList currentChoices = choice->currentChoices(); if (currentChoices.count() == 1) { - return KJSString(choice->exportValueForChoice(choice->choices().at(currentChoices[0]))); + result = KJSString(choice->exportValueForChoice(choice->choices().at(currentChoices[0]))); } break; } @@ -156,7 +160,8 @@ static KJSObject fieldGetValue(KJSContext * /*context*/, void *object) } } - return KJSUndefined(); + qCDebug(OkularCoreDebug) << "fieldGetValue: Field: " << field->fullyQualifiedName() << " Type: " << fieldGetTypeHelper(field) << " Value: " << result.toString(context) << (result.isString() ? "(as string)" : ""); + return result; } // Field.value (setter) @@ -164,6 +169,7 @@ static void fieldSetValue(KJSContext *context, void *object, KJSObject value) { FormField *field = reinterpret_cast(object); + qCDebug(OkularCoreDebug) << "fieldSetValue: Field: " << field->fullyQualifiedName() << " Type: " << fieldGetTypeHelper(field) << " Value: " << value.toString(context); switch (field->type()) { case FormField::FormButton: { FormFieldButton *button = static_cast(field);