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:
Aaron J. Seigo 2010-02-28 15:13:54 +00:00
parent 320d5f8f69
commit 3ce97e4d1d
3 changed files with 12 additions and 15 deletions

View File

@ -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));
}

View File

@ -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));
}

View File

@ -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<QGraphicsWidget *>(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));
}