diff --git a/scriptengines/javascript/simplebindings/anchorlayout.cpp b/scriptengines/javascript/simplebindings/anchorlayout.cpp index eda2a3f06..c41fb3b3b 100644 --- a/scriptengines/javascript/simplebindings/anchorlayout.cpp +++ b/scriptengines/javascript/simplebindings/anchorlayout.cpp @@ -48,11 +48,7 @@ QGraphicsLayoutItem *extractLayoutItem (QScriptContext *ctx, int index = 0); static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng) { QGraphicsLayoutItem *parent = extractLayoutItem(ctx); - - if (!parent) { - return ctx->throwError(i18n("The parent must be a QGraphicsLayoutItem")); - } - + //FIXME: don't leak memory when parent is 0 return qScriptValueFromValue(eng, new QGraphicsAnchorLayout(parent)); } diff --git a/scriptengines/javascript/simplebindings/gridlayout.cpp b/scriptengines/javascript/simplebindings/gridlayout.cpp index 5b2c9df05..7bef3501f 100644 --- a/scriptengines/javascript/simplebindings/gridlayout.cpp +++ b/scriptengines/javascript/simplebindings/gridlayout.cpp @@ -77,11 +77,7 @@ QGraphicsLayoutItem *extractLayoutItem(QScriptContext *ctx, int index = 0); static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng) { QGraphicsLayoutItem *parent = extractLayoutItem(ctx); - - if (!parent) { - return ctx->throwError(i18n("The parent must be a QGraphicsLayoutItem")); - } - + //FIXME: don't leak memory when parent is 0 return qScriptValueFromValue(eng, new QGraphicsGridLayout(parent)); } diff --git a/scriptengines/javascript/simplebindings/linearlayout.cpp b/scriptengines/javascript/simplebindings/linearlayout.cpp index 79b0d4e65..60c06270b 100644 --- a/scriptengines/javascript/simplebindings/linearlayout.cpp +++ b/scriptengines/javascript/simplebindings/linearlayout.cpp @@ -64,6 +64,10 @@ QGraphicsLayoutItem *extractLayoutItem(QScriptContext *ctx, int index = 0) } } + if (w->layout()) { + return 0; + } + return w; } @@ -88,17 +92,18 @@ QGraphicsLayoutItem *extractLayoutItem(QScriptContext *ctx, int index = 0) } } + QGraphicsWidget *w = dynamic_cast(item); + if (w && w->layout()) { + return 0; + } + return item; } static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng) { QGraphicsLayoutItem *parent = extractLayoutItem(ctx); - - if (!parent) { - return ctx->throwError(i18n("The parent must be a QGraphicsLayoutItem")); - } - + //FIXME: don't leak memory when parent is 0 return qScriptValueFromValue(eng, new QGraphicsLinearLayout(parent)); }