Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'jb48333' into 'master'
[qtmozembed] Interpret QVariant::type() as QMetaType::Type like it should. Fixes JB#48333

See merge request mer-core/qtmozembed!52
  • Loading branch information
rainemak committed Dec 11, 2019
2 parents 90d2103 + 8f60f7d commit 6e13457
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/qmozenginesettings.cpp
Expand Up @@ -116,7 +116,7 @@ void QMozEngineSettingsPrivate::enableLowPrecisionBuffers(bool enabled)

void QMozEngineSettingsPrivate::setPreference(const QString &key, const QVariant &value)
{
qCDebug(lcEmbedLiteExt) << "name:" << key.toUtf8().data() << ", type:" << value.type();
qCDebug(lcEmbedLiteExt) << "name:" << key.toUtf8().data() << ", type:" << value.type() << ", user type:" << value.userType();

if (!isInitialized()) {
qCDebug(lcEmbedLiteExt) << "Error: context not yet initialized";
Expand All @@ -126,28 +126,24 @@ void QMozEngineSettingsPrivate::setPreference(const QString &key, const QVariant

mozilla::embedlite::EmbedLiteApp *app = QMozContext::instance()->GetApp();

switch (value.type()) {
case QVariant::String:
int type = value.type();
switch (type) {
case QMetaType::QString:
case QMetaType::Float:
case QMetaType::Double:
app->SetCharPref(key.toUtf8().data(), value.toString().toUtf8().data());
break;
case QVariant::Int:
case QVariant::UInt:
case QVariant::LongLong:
case QVariant::ULongLong:
case QMetaType::Int:
case QMetaType::UInt:
case QMetaType::LongLong:
case QMetaType::ULongLong:
app->SetIntPref(key.toUtf8().data(), value.toInt());
break;
case QVariant::Bool:
case QMetaType::Bool:
app->SetBoolPref(key.toUtf8().data(), value.toBool());
break;
case QVariant::Double:
if (value.canConvert<int>()) {
app->SetIntPref(key.toUtf8().data(), value.toInt());
} else {
app->SetCharPref(key.toUtf8().data(), value.toString().toUtf8().data());
}
break;
default:
qCWarning(lcEmbedLiteExt) << "Unknown pref type:" << value.type();
qCWarning(lcEmbedLiteExt) << "Unknown pref" << key << "value" << value << "type:" << value.type() << "userType:" << value.userType();
}
}

Expand Down

0 comments on commit 6e13457

Please sign in to comment.