WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED INVALID
Bug 105441
[Qt][bridge] JavaScript null and undefined are mapped to the same QVariant type
https://bugs.webkit.org/show_bug.cgi?id=105441
Summary
[Qt][bridge] JavaScript null and undefined are mapped to the same QVariant type
Simon Hausmann
Reported
2012-12-19 08:43:56 PST
null and undefined are both mapped to a default constructed QVariant(), which means we cannot later distinguish between undefined and null when converting back to JavaScript. This means a loss of information. In Qt 5's QML null is mapped to QVariant(QMetaType::VoidStar, 0) and undefined is mapped to a default constructed QVariant (where the type is indeed unknown). We should fix this in Qt 5.1, I have a preliminary patch.
Attachments
Patch
(5.55 KB, patch)
2012-12-19 08:51 PST
,
Simon Hausmann
no flags
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Simon Hausmann
Comment 1
2012-12-19 08:51:24 PST
Created
attachment 180177
[details]
Patch Preliminary patch that still needs more fixing in the unit tests
Allan Sandfeld Jensen
Comment 2
2012-12-19 09:03:37 PST
Comment on
attachment 180177
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=180177&action=review
Mapping null to default QVariant seems to be consistant with QScript but not QJs (from Qml).
> Source/WebCore/bridge/qt/qt_runtime.cpp:680 > + if (type == QMetaType::VoidStar && !variant.value<void*>())
Are you sure this shouldn't just be a variant.isNull()? Wouldn't we want null QString to become null JS-values, instead of empty strings?
Simon Hausmann
Comment 3
2012-12-20 01:31:13 PST
(In reply to
comment #2
)
> (From update of
attachment 180177
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=180177&action=review
> > Mapping null to default QVariant seems to be consistant with QScript but not QJs (from Qml).
Right.
> > Source/WebCore/bridge/qt/qt_runtime.cpp:680 > > + if (type == QMetaType::VoidStar && !variant.value<void*>()) > > Are you sure this shouldn't just be a variant.isNull()? Wouldn't we want null QString to become null JS-values, instead of empty strings?
I think the main argument against it is that you loose the information that it was a _string_. I'm personally not a big fan of the null vs. empty distinction for strings and I recall discussions about getting rid of it altogether with Qt 4, but we couldn't because it would break too much existing code.
Jocelyn Turcotte
Comment 4
2014-02-03 03:24:05 PST
=== Bulk closing of Qt bugs === If you believe that this bug report is still relevant for a non-Qt port of webkit.org, please re-open it and remove [Qt] from the summary. If you believe that this is still an important QtWebKit bug, please fill a new report at
https://bugreports.qt-project.org
and add a link to this issue. See
http://qt-project.org/wiki/ReportingBugsInQt
for additional guidelines.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug