diff options
author | Janne Anttila <janne.anttila@digia.com> | 2009-08-05 12:28:13 (GMT) |
---|---|---|
committer | Janne Anttila <janne.anttila@digia.com> | 2009-08-05 12:28:13 (GMT) |
commit | b53192d51cf8064dcb4361b3032d1e39260f4eea (patch) | |
tree | 183bd2a0ade9b580513e03dbde4798f43e33e855 /src | |
parent | 3bd102e7935fcb002867acfd72c34b38247144da (diff) | |
parent | 638edc80e3b224a6830dda0a2bd3097cb82dcb96 (diff) | |
download | Qt-b53192d51cf8064dcb4361b3032d1e39260f4eea.zip Qt-b53192d51cf8064dcb4361b3032d1e39260f4eea.tar.gz Qt-b53192d51cf8064dcb4361b3032d1e39260f4eea.tar.bz2 |
Merge branch 'master' of git@scm.dev.troll.no:qt/qt-s60-public
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/itemviews/qstandarditemmodel.cpp | 20 | ||||
-rw-r--r-- | src/gui/itemviews/qstandarditemmodel_p.h | 4 | ||||
-rw-r--r-- | src/gui/kernel/qwidget_s60.cpp | 44 |
3 files changed, 37 insertions, 31 deletions
diff --git a/src/gui/itemviews/qstandarditemmodel.cpp b/src/gui/itemviews/qstandarditemmodel.cpp index b960fae..25acbc4 100644 --- a/src/gui/itemviews/qstandarditemmodel.cpp +++ b/src/gui/itemviews/qstandarditemmodel.cpp @@ -329,7 +329,6 @@ QStandardItemModelPrivate::QStandardItemModelPrivate() */ QStandardItemModelPrivate::~QStandardItemModelPrivate() { - delete root; delete itemPrototype; qDeleteAll(columnHeaderItems); qDeleteAll(rowHeaderItems); @@ -554,7 +553,7 @@ void QStandardItemModelPrivate::rowsInserted(QStandardItem *parent, int row, int count) { Q_Q(QStandardItemModel); - if (parent == root) + if (parent == root.data()) rowHeaderItems.insert(row, count, 0); q->endInsertRows(); } @@ -566,7 +565,7 @@ void QStandardItemModelPrivate::columnsInserted(QStandardItem *parent, int column, int count) { Q_Q(QStandardItemModel); - if (parent == root) + if (parent == root.data()) columnHeaderItems.insert(column, count, 0); q->endInsertColumns(); } @@ -578,7 +577,7 @@ void QStandardItemModelPrivate::rowsRemoved(QStandardItem *parent, int row, int count) { Q_Q(QStandardItemModel); - if (parent == root) { + if (parent == root.data()) { for (int i = row; i < row + count; ++i) { QStandardItem *oldItem = rowHeaderItems.at(i); if (oldItem) @@ -597,7 +596,7 @@ void QStandardItemModelPrivate::columnsRemoved(QStandardItem *parent, int column, int count) { Q_Q(QStandardItemModel); - if (parent == root) { + if (parent == root.data()) { for (int i = column; i < column + count; ++i) { QStandardItem *oldItem = columnHeaderItems.at(i); if (oldItem) @@ -788,7 +787,7 @@ QStandardItem::~QStandardItem() QStandardItem *QStandardItem::parent() const { Q_D(const QStandardItem); - if (!d->model || (d->model->d_func()->root != d->parent)) + if (!d->model || (d->model->d_func()->root.data() != d->parent)) return d->parent; return 0; } @@ -2083,8 +2082,7 @@ QStandardItemModel::~QStandardItemModel() void QStandardItemModel::clear() { Q_D(QStandardItemModel); - delete d->root; - d->root = new QStandardItem; + d->root.reset(new QStandardItem); d->root->d_func()->setModel(this); qDeleteAll(d->columnHeaderItems); d->columnHeaderItems.clear(); @@ -2231,7 +2229,7 @@ QStandardItem *QStandardItemModel::item(int row, int column) const QStandardItem *QStandardItemModel::invisibleRootItem() const { Q_D(const QStandardItemModel); - return d->root; + return d->root.data(); } /*! @@ -2733,7 +2731,7 @@ QModelIndex QStandardItemModel::index(int row, int column, const QModelIndex &pa bool QStandardItemModel::insertColumns(int column, int count, const QModelIndex &parent) { Q_D(QStandardItemModel); - QStandardItem *item = parent.isValid() ? itemFromIndex(parent) : d->root; + QStandardItem *item = parent.isValid() ? itemFromIndex(parent) : d->root.data(); if (item == 0) return false; return item->d_func()->insertColumns(column, count, QList<QStandardItem*>()); @@ -2745,7 +2743,7 @@ bool QStandardItemModel::insertColumns(int column, int count, const QModelIndex bool QStandardItemModel::insertRows(int row, int count, const QModelIndex &parent) { Q_D(QStandardItemModel); - QStandardItem *item = parent.isValid() ? itemFromIndex(parent) : d->root; + QStandardItem *item = parent.isValid() ? itemFromIndex(parent) : d->root.data(); if (item == 0) return false; return item->d_func()->insertRows(row, count, QList<QStandardItem*>()); diff --git a/src/gui/itemviews/qstandarditemmodel_p.h b/src/gui/itemviews/qstandarditemmodel_p.h index b2b16d1..8be8e9e 100644 --- a/src/gui/itemviews/qstandarditemmodel_p.h +++ b/src/gui/itemviews/qstandarditemmodel_p.h @@ -152,7 +152,7 @@ public: inline QStandardItem *itemFromIndex(const QModelIndex &index) const { Q_Q(const QStandardItemModel); if (!index.isValid()) - return root; + return root.data(); if (index.model() != q) return 0; QStandardItem *parent = static_cast<QStandardItem*>(index.internalPointer()); @@ -177,7 +177,7 @@ public: QVector<QStandardItem*> columnHeaderItems; QVector<QStandardItem*> rowHeaderItems; - QStandardItem *root; + QScopedPointer<QStandardItem> root; const QStandardItem *itemPrototype; int sortRole; }; diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index ddd2f4c..4336d45 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -299,6 +299,7 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de CCoeControl *destroyw = 0; + createExtra(); if(window) { if (destroyOldWindow) destroyw = data.winid; @@ -311,7 +312,10 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de if (!q->testAttribute(Qt::WA_Moved) && !q->testAttribute(Qt::WA_DontShowOnScreen)) data.crect.moveTopLeft(QPoint(clientRect.iTl.iX, clientRect.iTl.iY)); QSymbianControl *control= q_check_ptr(new QSymbianControl(q)); + id = (WId)control; + setWinId(id); QT_TRAP_THROWING(control->ConstructL(true,desktop)); + if (!desktop) { TInt stackingFlags; if ((q->windowType() & Qt::Popup) == Qt::Popup) { @@ -336,11 +340,6 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de } } - - id = (WId)control; - - setWinId(id); - q->setAttribute(Qt::WA_WState_Created); int x, y, w, h; @@ -348,6 +347,7 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de control->SetRect(TRect(TPoint(x, y), TSize(w, h))); } else if (q->testAttribute(Qt::WA_NativeWindow) || paintOnScreen()) { // create native child widget QSymbianControl *control = new QSymbianControl(q); + setWinId(control); QT_TRAP_THROWING(control->ConstructL(!parentWidget)); TInt stackingFlags; @@ -358,7 +358,6 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de } control->ControlEnv()->AppUi()->AddToStackL(control, ECoeStackPriorityDefault, stackingFlags); - setWinId(control); WId parentw = parentWidget->effectiveWinId(); QT_TRAP_THROWING(control->SetContainerWindowL(*parentw)); @@ -852,7 +851,12 @@ void QWidgetPrivate::createSysExtra() void QWidgetPrivate::deleteSysExtra() { - + // this should only be non-zero if destroy() has not run due to constructor fail + if (data.winid) { + data.winid->ControlEnv()->AppUi()->RemoveFromStack(data.winid); + delete data.winid; + data.winid = 0; + } } QWindowSurface *QWidgetPrivate::createDefaultWindowSurface_sys() @@ -1079,6 +1083,7 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows) if (!isWindow() && parentWidget()) parentWidget()->d_func()->invalidateBuffer(geometry()); d->deactivateWidgetCleanup(); + WId id = internalWinId(); if (testAttribute(Qt::WA_WState_Created)) { #ifndef QT_NO_IM @@ -1104,12 +1109,10 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows) releaseMouse(); if (QWidgetPrivate::keyboardGrabber == this) releaseKeyboard(); - if (destroyWindow && !(windowType() == Qt::Desktop) && internalWinId()) { - WId id = internalWinId(); + if (destroyWindow && !(windowType() == Qt::Desktop) && id) { if(id->IsFocused()) // Avoid unnecessry calls to FocusChanged() id->SetFocus(false); id->ControlEnv()->AppUi()->RemoveFromStack(id); - CBase::Delete(id); // Hack to activate window under destroyed one. With this activation // the next visible window will get keyboard focus @@ -1117,17 +1120,22 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows) if (wid) { QWidget *widget = QWidget::find(wid); QApplication::setActiveWindow(widget); - // Reset global window title for focusing window - widget->d_func()->setWindowTitle_sys(widget->windowTitle()); + if (widget) { + // Reset global window title for focusing window + widget->d_func()->setWindowTitle_sys(widget->windowTitle()); + } } - } + } - QT_TRY { - d->setWinId(0); - } QT_CATCH (const std::bad_alloc &) { - // swallow - destructors must not throw - } + QT_TRY { + d->setWinId(0); + } QT_CATCH (const std::bad_alloc &) { + // swallow - destructors must not throw + } + + if (destroyWindow) { + delete id; } } |