[Interest] Qml Object prototype generate errors

Jérôme Godbout jerome at bodycad.com
Tue Nov 29 16:49:25 CET 2016


Hi,
We are on Qt 5.5.1 and we try to add javascript Object prototype like this

.pragma library
Object.prototype.values = function(o)
{
   return Object.keys(o || {}).map(function(i){ return o[i]; });
}

We want to add the ECMA-2017 features, remove it when available into the JS
engine:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values

This give us some problem with javascript map for( in ) loop, but that's
okay we can fix them with Object.keys.forEach(). But I also get an error
with the Table View

Qt55/msvc2015_64_opengl/qml/QtQuick/Controls/Private/BasicTableView.qml:695:
ReferenceError: modelData is not defined

This line reference the modelData, for an empty table view this seem to
failed and have an entry for values property of object for some reason.

I would like to know if this is prohibited to add prototype to Object or we
are conflicting with something else here? Or is it just a bug into the
table view binding code.

Why adding a prototype to Object break the for in loop with empty map?

var objects = {};
for(var key in objects)
{
   console.log('my key is ' + key); //--> my key is values
}


[image: bodycad] <https://www.bodycad.com/>
Jerome Godbout
Software Developer
2035 rue du Haut-Bord, Québec, QC, Canada. G1N 4R7
T:  +1 418 527-1388
E: jerome at bodycad.com
www.bodycad.com

The contents of this email message and any attachments are intended solely
for the addressee(s) and may contain confidential and/or privileged
information and may be legally protected from disclosure. If you are not
the intended recipient of this message or their agent, or if this message
has been addressed to you in error, please immediately alert the sender by
reply email and then delete this message and any attachments. If you are
not the intended recipient, you are hereby notified that any use,
dissemination, copying, or storage of this message or its attachments is
strictly prohibited.

Le contenu de ce message et les pièces jointes sont destinés uniquement
pour le(s) destinataire(s) et peuvent contenir des informations
confidentielles et / ou privilégiées qui peuvent être protégées légalement
contre toute divulgation. Si vous n'êtes pas le destinataire de ce message
ou son agent, ou si ce message vous a été adressé par erreur, s’il vous
plaît avertir immédiatement l'expéditeur par courriel de réponse, puis
supprimer ce message et les pièces jointes. Si vous n'êtes pas le
destinataire prévu, vous êtes par la présente informé que toute
utilisation, diffusion, copie, ou stockage de ce message ou de ses pièces
jointes est strictement interdit.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20161129/8ca7b65d/attachment.html>


More information about the Interest mailing list