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

« back to all changes in this revision

Viewing changes to PySide/QtGui/glue/qapplication_init.cpp

  • 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:
5
5
static char** QApplicationArgValues;
6
6
static const char QAPP_MACRO[] = "qApp";
7
7
 
8
 
void DeleteQApplicationAtExit()
9
 
{
10
 
    PySide::SignalManager::instance().clear();
11
 
    QCoreApplication* cpp = QApplication::instance();
12
 
    if (cpp) {
13
 
        Shiboken::BindingManager &bmngr = Shiboken::BindingManager::instance();
14
 
 
15
 
        // Delete all widgets, this is slow but is necessary to avoid problems with python object
16
 
        foreach(QWidget* w, QApplication::allWidgets()) {
17
 
            PyObject* wrapper = bmngr.retrieveWrapper(w);
18
 
            if (wrapper) {
19
 
                if (SbkBaseWrapper_hasOwnership(wrapper))
20
 
                    delete w; // destroy C++ object and invalidate wrapper object
21
 
                else
22
 
                    bmngr.destroyWrapper(wrapper); // only invalidate wrapper object
23
 
            }
24
 
        }
25
 
        cpp->flush();
26
 
        delete cpp;
27
 
    }
28
 
}
29
 
 
30
 
int SbkQApplication_Init(PyObject* self, PyObject* args, PyObject*)
31
 
{
32
 
    if (Shiboken::isUserType(self) && !Shiboken::canCallConstructor(self->ob_type, Shiboken::SbkType<QApplication >()))
 
8
int Sbk_QApplication_Init(PyObject* self, PyObject* args, PyObject*)
 
9
{
 
10
    if (Shiboken::Object::isUserType(self) && !Shiboken::ObjectType::canCallConstructor(self->ob_type, Shiboken::SbkType<QApplication>()))
33
11
        return -1;
34
12
 
35
13
    if (QApplication::instance()) {
43
21
        return -1;
44
22
    }
45
23
 
46
 
    if (!PySequenceToArgcArgv(PyTuple_GET_ITEM(args, 0), &QApplicationArgCount, &QApplicationArgValues, "PySideApp")) {
 
24
    if (!Shiboken::sequenceToArgcArgv(PyTuple_GET_ITEM(args, 0), &QApplicationArgCount, &QApplicationArgValues, "PySideApp")) {
47
25
        PyErr_BadArgument();
48
26
        return -1;
49
27
    }
50
28
 
 
29
    SbkObject* sbkSelf = reinterpret_cast<SbkObject*>(self);
51
30
    QApplicationWrapper* cptr = new QApplicationWrapper(QApplicationArgCount, QApplicationArgValues);
52
 
    Shiboken::setCppPointer(reinterpret_cast<SbkBaseWrapper*>(self),
53
 
                            Shiboken::SbkType<QApplication>(),
54
 
                            cptr);
55
 
    SbkBaseWrapper_setValidCppObject(self, 1);
56
 
    SbkBaseWrapper *sbkSelf = reinterpret_cast<SbkBaseWrapper*>(self);
57
 
    sbkSelf->containsCppWrapper = 1;
58
 
    sbkSelf->hasOwnership = 0;
 
31
    Shiboken::Object::setCppPointer(sbkSelf,
 
32
                                     Shiboken::SbkType<QApplication>(),
 
33
                                     cptr);
 
34
    Shiboken::Object::setValidCpp(sbkSelf, true);
 
35
    Shiboken::Object::setHasCppWrapper(sbkSelf, true);
 
36
    Shiboken::Object::releaseOwnership(sbkSelf);
59
37
    Shiboken::BindingManager::instance().registerWrapper(sbkSelf, cptr);
60
 
    PySide::signalUpdateSource(self);
 
38
    PySide::Signal::updateSourceObject(self);
61
39
    cptr->metaObject();
62
40
 
63
41
    // Verify if qApp is in main module
69
47
    }
70
48
 
71
49
    PyObject_SetAttrString(moduleQtGui, QAPP_MACRO, self);
72
 
    PySide::registerCleanupFunction(DeleteQApplicationAtExit);
 
50
    PySide::registerCleanupFunction(&PySide::destroyQCoreApplication);
73
51
    Py_INCREF(self);
74
52
    return 1;
75
53
}