make painters on random pixmaps work; you still need to take of things like calling end()

BUG:266018
This commit is contained in:
Aaron Seigo 2011-12-08 17:54:34 +01:00
parent 2435f1cc6a
commit 08fae507f1
3 changed files with 12 additions and 3 deletions

View File

@ -21,6 +21,10 @@
#include <QtCore/QSharedData>
#include <QPixmap>
Q_DECLARE_METATYPE(QPixmap*)
Q_DECLARE_METATYPE(QPixmap)
#define DECLARE_SELF(Class, __fn__) \
Class* self = qscriptvalue_cast<Class*>(ctx->thisObject()); \
if (!self) { \

View File

@ -50,6 +50,14 @@ static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
{
if (ctx->argumentCount() > 0) {
QPaintDevice *device = qscriptvalue_cast<QPaintDevice*>(ctx->argument(0));
if (!device) {
QPixmap *pixmap = qscriptvalue_cast<QPixmap *>(ctx->argument(0));
if (pixmap) {
return newPainter(eng, new QPainter(pixmap));
} else {
return newPainter(eng, new QPainter());
}
}
return newPainter(eng, new QPainter(device));
} else {
return newPainter(eng, new QPainter());

View File

@ -23,9 +23,6 @@
#include "backportglobal.h"
#include "plasmoid/appletinterface.h"
Q_DECLARE_METATYPE(QPixmap*)
Q_DECLARE_METATYPE(QPixmap)
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
{
if (ctx->argumentCount() == 1 && ctx->argument(0).isString()) {