~ubuntu-branches/ubuntu/natty/pyside/natty-proposed

« back to all changes in this revision

Viewing changes to PySide/QtGui/glue/qwidget_glue.h

  • Committer: Bazaar Package Importer
  • Author(s): Didier Raboud
  • Date: 2011-02-18 18:01:00 UTC
  • mfrom: (1.2.3 upstream) (6.1.6 experimental)
  • Revision ID: james.westby@ubuntu.com-20110218180100-vaczjij7g08fzfme
Tags: 1.0.0~rc1-1
* New 1.0.0~rc1 upstream release
  - Bump the B-D chain versions:
    + apiextractor to 0.10.0-2~
    + generatorrunner to 0.6.6
    + shiboken to 1.0.0~rc1
* Update patches to ~rc1.
* debian/watch: update to handle Release Candidates too.
* Bump XS-Python-Version to >= 2.6.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
/**
9
9
 * Tranfer objects ownership from layout to widget
10
10
 **/
11
 
static inline void
12
 
qwidgetReparentLayout(QWidget *parent, QLayout *layout)
 
11
static inline void qwidgetReparentLayout(QWidget *parent, QLayout *layout)
13
12
{
14
13
    Shiboken::AutoDecRef pyParent(Shiboken::Converter<QWidget*>::toPython(parent));
15
14
 
16
 
    for (int i=0; i < layout->count(); i++)
17
 
    {
18
 
        QLayoutItem *item = layout->itemAt(i);
19
 
        QWidget *w = item->widget();
20
 
        if (w)
21
 
        {
 
15
    for (int i=0; i < layout->count(); i++) {
 
16
        QLayoutItem* item = layout->itemAt(i);
 
17
        if (PyErr_Occurred() || !item)
 
18
            return;
 
19
 
 
20
        QWidget* w = item->widget();
 
21
        if (w) {
22
22
            QWidget* pw = w->parentWidget();
23
23
            if (pw != parent) {
24
24
                Shiboken::AutoDecRef pyChild(Shiboken::Converter<QWidget*>::toPython(w));
25
 
                Shiboken::setParent(pyParent, pyChild);
 
25
                Shiboken::Object::setParent(pyParent, pyChild);
26
26
            }
27
 
        }
28
 
        else
29
 
        {
30
 
            QLayout *l = item->layout();
 
27
        } else {
 
28
            QLayout* l = item->layout();
31
29
            if (l)
32
30
                qwidgetReparentLayout(parent, l);
33
31
        }
34
32
    }
35
33
 
36
34
    Shiboken::AutoDecRef pyChild(Shiboken::Converter<QLayout*>::toPython(layout));
37
 
    Shiboken::setParent(pyParent, pyChild);
 
35
    Shiboken::Object::setParent(pyParent, pyChild);
38
36
    //remove previous references
39
 
    Shiboken::keepReference(reinterpret_cast<Shiboken::SbkBaseWrapper*>(pyChild.object()), qPrintable(retrieveObjectName(pyChild)), Py_None);
 
37
    Shiboken::Object::keepReference(reinterpret_cast<SbkObject*>(pyChild.object()), qPrintable(retrieveObjectName(pyChild)), Py_None);
40
38
}
41
39
 
42
 
static inline void
43
 
qwidgetSetLayout(QWidget *self, QLayout *layout)
 
40
static inline void qwidgetSetLayout(QWidget *self, QLayout *layout)
44
41
{
45
42
    if (!layout || self->layout())
46
43
        return;
50
47
        if (oldParent->isWidgetType()) {
51
48
            // remove old parent policy
52
49
            Shiboken::AutoDecRef pyLayout(Shiboken::Converter<QLayout*>::toPython(layout));
53
 
            Shiboken::setParent(Py_None, pyLayout);
 
50
            Shiboken::Object::setParent(Py_None, pyLayout);
54
51
        } else {
55
52
            PyErr_Format(PyExc_RuntimeError, "QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", when the QLayout already has a parent",
56
53
                          qPrintable(layout->objectName()), self->metaObject()->className(), qPrintable(self->objectName()));
60
57
 
61
58
    if (oldParent != self) {
62
59
        qwidgetReparentLayout(self, layout);
 
60
        if (PyErr_Occurred())
 
61
            return;
 
62
 
63
63
        self->setLayout(layout);
64
64
    }
65
65
}