until there is a better solution (e.g. one that doesn't lead to crashes due to dangling pointers in random QScriptValue objects), don't quietly add layouts to existing QGraphicsWidgets that already have a layout
svn path=/trunk/KDE/kdebase/runtime/; revision=1097160
This commit is contained in:
parent
320d5f8f69
commit
3ce97e4d1d
@ -48,11 +48,7 @@ QGraphicsLayoutItem *extractLayoutItem (QScriptContext *ctx, int index = 0);
|
|||||||
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
|
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
|
||||||
{
|
{
|
||||||
QGraphicsLayoutItem *parent = extractLayoutItem(ctx);
|
QGraphicsLayoutItem *parent = extractLayoutItem(ctx);
|
||||||
|
//FIXME: don't leak memory when parent is 0
|
||||||
if (!parent) {
|
|
||||||
return ctx->throwError(i18n("The parent must be a QGraphicsLayoutItem"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return qScriptValueFromValue(eng, new QGraphicsAnchorLayout(parent));
|
return qScriptValueFromValue(eng, new QGraphicsAnchorLayout(parent));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,11 +77,7 @@ QGraphicsLayoutItem *extractLayoutItem(QScriptContext *ctx, int index = 0);
|
|||||||
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
|
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
|
||||||
{
|
{
|
||||||
QGraphicsLayoutItem *parent = extractLayoutItem(ctx);
|
QGraphicsLayoutItem *parent = extractLayoutItem(ctx);
|
||||||
|
//FIXME: don't leak memory when parent is 0
|
||||||
if (!parent) {
|
|
||||||
return ctx->throwError(i18n("The parent must be a QGraphicsLayoutItem"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return qScriptValueFromValue(eng, new QGraphicsGridLayout(parent));
|
return qScriptValueFromValue(eng, new QGraphicsGridLayout(parent));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,6 +64,10 @@ QGraphicsLayoutItem *extractLayoutItem(QScriptContext *ctx, int index = 0)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (w->layout()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,17 +92,18 @@ QGraphicsLayoutItem *extractLayoutItem(QScriptContext *ctx, int index = 0)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QGraphicsWidget *w = dynamic_cast<QGraphicsWidget *>(item);
|
||||||
|
if (w && w->layout()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
|
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
|
||||||
{
|
{
|
||||||
QGraphicsLayoutItem *parent = extractLayoutItem(ctx);
|
QGraphicsLayoutItem *parent = extractLayoutItem(ctx);
|
||||||
|
//FIXME: don't leak memory when parent is 0
|
||||||
if (!parent) {
|
|
||||||
return ctx->throwError(i18n("The parent must be a QGraphicsLayoutItem"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return qScriptValueFromValue(eng, new QGraphicsLinearLayout(parent));
|
return qScriptValueFromValue(eng, new QGraphicsLinearLayout(parent));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user