From 978416807b7e92d9317036cb4348ee172dde7d4e Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Fri, 8 Oct 2010 09:08:54 +0200 Subject: Fix memory leak in QPixmap::toSymbianRSgImage() when an error occurs. In the cases where an error occured while converting a QPixmap to a VGImage this function would return without deleting the RSgImage pointer that it created. Fix is to use a QScopedPointer instead. Also don't use q_check_ptr() since this isn't a CBase derived class. In case you are wondering why I didn't use a custom deleter here so that Close() was also called, we need to make sure that Close() is called on the RSgImage instance before calling Close() on the driver. Reviewed-by: mread --- src/openvg/qvg_symbian.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/openvg/qvg_symbian.cpp b/src/openvg/qvg_symbian.cpp index ef0160c..a9625b2 100644 --- a/src/openvg/qvg_symbian.cpp +++ b/src/openvg/qvg_symbian.cpp @@ -228,7 +228,7 @@ void* QVGPixmapData::toNativeType(NativeType type) sgInfo.iSizeInPixels.SetSize(w, h); sgInfo.iUsage = ESgUsageBitOpenVgImage | ESgUsageBitOpenVgSurface; - RSgImage *sgImage = q_check_ptr(new RSgImage()); + QScopedPointer sgImage(new RSgImage()); err = sgImage->Create(sgInfo, NULL, NULL); if (err != KErrNone) { driver.Close(); @@ -239,7 +239,7 @@ void* QVGPixmapData::toNativeType(NativeType type) EGLImageKHR eglImage = QEgl::eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, - (EGLClientBuffer)sgImage, + (EGLClientBuffer)sgImage.data(), (EGLint*)KEglImageAttribs); if (!eglImage || eglGetError() != EGL_SUCCESS) { sgImage->Close(); @@ -261,13 +261,14 @@ void* QVGPixmapData::toNativeType(NativeType type) if (vgGetError() != VG_NO_ERROR) { sgImage->Close(); - sgImage = 0; + sgImage.reset(); } + // release stuff vgDestroyImage(dstVgImage); QEgl::eglDestroyImageKHR(QEgl::display(), eglImage); driver.Close(); - return reinterpret_cast(sgImage); + return reinterpret_cast(sgImage.take()); #endif } else if (type == QPixmapData::FbsBitmap) { CFbsBitmap *bitmap = q_check_ptr(new CFbsBitmap); -- cgit v0.12 From 7ca4e9622c4b2e4142d401fa10d50a0a45906615 Mon Sep 17 00:00:00 2001 From: axis Date: Thu, 7 Oct 2010 15:26:47 +0200 Subject: Fixed missing QMAKE_MOC definition in certain mkspecs. Also removed the use of DIR_SEPARATOR. It does not get defined until after symbian.conf has finished parsing. RevBy: Miikka Heikkinen --- mkspecs/common/symbian/symbian-mmp.conf | 10 ---------- mkspecs/common/symbian/symbian.conf | 8 ++++++++ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/mkspecs/common/symbian/symbian-mmp.conf b/mkspecs/common/symbian/symbian-mmp.conf index 5292781..1fbd302 100644 --- a/mkspecs/common/symbian/symbian-mmp.conf +++ b/mkspecs/common/symbian/symbian-mmp.conf @@ -4,16 +4,6 @@ include(symbian.conf) -contains(QMAKE_HOST.os, "Windows") { - QMAKE_MOC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}moc.exe - QMAKE_UIC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}uic.exe - QMAKE_IDC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}idc.exe -} else { - QMAKE_MOC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}moc - QMAKE_UIC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}uic - QMAKE_IDC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}idc -} - load(symbian/add_mmp_rules) symbian-abld { diff --git a/mkspecs/common/symbian/symbian.conf b/mkspecs/common/symbian/symbian.conf index cc5b788..d8c38f4 100644 --- a/mkspecs/common/symbian/symbian.conf +++ b/mkspecs/common/symbian/symbian.conf @@ -95,6 +95,10 @@ contains(QMAKE_HOST.os,Windows) { QMAKE_DEL_DIR = rmdir QMAKE_DEL_TREE = rmdir /s /q QMAKE_CHK_DIR_EXISTS = if not exist + + QMAKE_MOC = $$[QT_INSTALL_BINS]\\moc.exe + QMAKE_UIC = $$[QT_INSTALL_BINS]\\uic.exe + QMAKE_IDC = $$[QT_INSTALL_BINS]\\idc.exe } else { QMAKE_COPY = cp QMAKE_COPY_DIR = cp -r @@ -104,6 +108,10 @@ contains(QMAKE_HOST.os,Windows) { QMAKE_DEL_DIR = rmdir QMAKE_DEL_TREE = rm -rf QMAKE_CHK_DIR_EXISTS = test -d + + QMAKE_MOC = $$[QT_INSTALL_BINS]/moc + QMAKE_UIC = $$[QT_INSTALL_BINS]/uic + QMAKE_IDC = $$[QT_INSTALL_BINS]/idc } QMAKE_IDL = midl -- cgit v0.12 From aa0f3a7745472ea8c9ca43bb7d690a0591bde83b Mon Sep 17 00:00:00 2001 From: axis Date: Fri, 8 Oct 2010 14:58:44 +0200 Subject: Fixed some preprocessor parameters for Mac support. RevBy: Liang Qi --- mkspecs/features/symbian/symbian_building.prf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mkspecs/features/symbian/symbian_building.prf b/mkspecs/features/symbian/symbian_building.prf index 614fb65..1a51cb2 100644 --- a/mkspecs/features/symbian/symbian_building.prf +++ b/mkspecs/features/symbian/symbian_building.prf @@ -229,7 +229,7 @@ symbian_resources_INCLUDES = $$replace(symbian_resources_INCLUDES, ",", " -I") symbian_resources_INCLUDES += $$join(INCLUDEPATH, " -I", "-I") symbian_resources_DEFINES = $$join(DEFINES, " -D", "-D") symbian_resources_RCC_DIR = $$replace(RCC_DIR, "/$", "") -symbian_resources_INCLUDES += "-I $$symbian_resources_RCC_DIR" +symbian_resources_INCLUDES += "-I$$symbian_resources_RCC_DIR" for(symbian_resource, SYMBIAN_RESOURCES) { symbian_resource = $$basename(symbian_resource) @@ -245,7 +245,7 @@ symbianresources.commands = cpp -nostdinc -undef \ $$symbian_resources_INCLUDES \ $$symbian_resources_DEFINES \ ${QMAKE_FILE_NAME} \ - -o $${symbian_resources_RCC_DIR}/${QMAKE_FILE_BASE}.rpp \ + > $${symbian_resources_RCC_DIR}/${QMAKE_FILE_BASE}.rpp \ && rcomp -u -m045,046,047 \ -s$${symbian_resources_RCC_DIR}/${QMAKE_FILE_BASE}.rpp \ -o$${symbianDestdir}/${QMAKE_FILE_BASE}$${QT_LIBINFIX}.rsc \ @@ -265,7 +265,7 @@ contains(TEMPLATE, "app"):!contains(CONFIG, "no_icon") { $$symbian_resources_INCLUDES \ $$symbian_resources_DEFINES \ $${baseTarget}.rss \ - -o $${symbian_resources_RCC_DIR}/$${baseTarget}.rpp \ + > $${symbian_resources_RCC_DIR}/$${baseTarget}.rpp \ && rcomp -u -m045,046,047 \ -s$${symbian_resources_RCC_DIR}/$${baseTarget}.rpp \ -o$${symbianDestdir}/$${baseTarget}.rsc \ @@ -284,7 +284,7 @@ contains(TEMPLATE, "app"):!contains(CONFIG, "no_icon") { $$symbian_resources_INCLUDES \ $$symbian_resources_DEFINES \ $${baseTarget}_reg.rss \ - -o $${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rpp \ + > $${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rpp \ && rcomp -u -m045,046,047 \ -s$${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rpp \ -o$${symbianDestdir}/$${baseTarget}_reg.rsc \ -- cgit v0.12 From 4ee912a752a4b7f129e98e180328f1f46f053d4f Mon Sep 17 00:00:00 2001 From: axis Date: Fri, 1 Oct 2010 13:25:28 +0200 Subject: Added support for using inputMethodHints in QInputDialog edit widget. AutoTest: Included Task: QTBUG-13200 RevBy: Denis Dzyubenko --- src/gui/dialogs/qinputdialog.cpp | 6 ++++++ src/gui/kernel/qwidget.cpp | 11 +++++++++-- src/gui/kernel/qwidget_p.h | 3 +++ tests/auto/qinputdialog/tst_qinputdialog.cpp | 20 ++++++++++++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/gui/dialogs/qinputdialog.cpp b/src/gui/dialogs/qinputdialog.cpp index e996ee9..700b234 100644 --- a/src/gui/dialogs/qinputdialog.cpp +++ b/src/gui/dialogs/qinputdialog.cpp @@ -244,6 +244,9 @@ void QInputDialogPrivate::ensureLineEdit() Q_Q(QInputDialog); if (!lineEdit) { lineEdit = new QLineEdit(q); +#ifndef QT_NO_IM + qt_widget_private(lineEdit)->inheritsInputMethodHints = 1; +#endif lineEdit->hide(); QObject::connect(lineEdit, SIGNAL(textChanged(QString)), q, SLOT(_q_textChanged(QString))); @@ -255,6 +258,9 @@ void QInputDialogPrivate::ensureComboBox() Q_Q(QInputDialog); if (!comboBox) { comboBox = new QComboBox(q); +#ifndef QT_NO_IM + qt_widget_private(comboBox)->inheritsInputMethodHints = 1; +#endif comboBox->hide(); QObject::connect(comboBox, SIGNAL(editTextChanged(QString)), q, SLOT(_q_textChanged(QString))); diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index dc0dbf4..330d699 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -273,6 +273,9 @@ QWidgetPrivate::QWidgetPrivate(int version) , isMoved(0) , isGLWidget(0) , usesDoubleBufferedGLContext(0) +#ifndef QT_NO_IM + , inheritsInputMethodHints(0) +#endif #if defined(Q_WS_X11) , picture(0) #elif defined(Q_WS_WIN) @@ -9228,9 +9231,13 @@ QVariant QWidget::inputMethodQuery(Qt::InputMethodQuery query) const */ Qt::InputMethodHints QWidget::inputMethodHints() const { - Q_D(const QWidget); #ifndef QT_NO_IM - return d->imHints; + const QWidgetPrivate *priv = d_func(); + while (priv->inheritsInputMethodHints) { + priv = priv->q_func()->parentWidget()->d_func(); + Q_ASSERT(priv); + } + return priv->imHints; #else //QT_NO_IM return 0; #endif //QT_NO_IM diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 4a79dc7..6c89659 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -748,6 +748,9 @@ public: uint isMoved : 1; uint isGLWidget : 1; uint usesDoubleBufferedGLContext : 1; +#ifndef QT_NO_IM + uint inheritsInputMethodHints : 1; +#endif // *************************** Platform specific ************************************ #if defined(Q_WS_X11) // <----------------------------------------------------------- X11 diff --git a/tests/auto/qinputdialog/tst_qinputdialog.cpp b/tests/auto/qinputdialog/tst_qinputdialog.cpp index 0d6644a..5d03142 100644 --- a/tests/auto/qinputdialog/tst_qinputdialog.cpp +++ b/tests/auto/qinputdialog/tst_qinputdialog.cpp @@ -74,6 +74,7 @@ private slots: void getItem_data(); void getItem(); void task256299_getTextReturnNullStringOnRejected(); + void inputMethodHintsOfChildWidget(); }; QString stripFraction(const QString &s) @@ -404,5 +405,24 @@ void tst_QInputDialog::getItem() delete parent; } +void tst_QInputDialog::inputMethodHintsOfChildWidget() +{ + QInputDialog dialog; + dialog.setInputMode(QInputDialog::TextInput); + QList children = dialog.children(); + QLineEdit *editWidget = 0; + for (int c = 0; c < children.size(); c++) { + editWidget = qobject_cast(children.at(c)); + if (editWidget) + break; + } + QVERIFY(editWidget); + QCOMPARE(editWidget->inputMethodHints(), dialog.inputMethodHints()); + QCOMPARE(editWidget->inputMethodHints(), Qt::ImhNone); + dialog.setInputMethodHints(Qt::ImhDigitsOnly); + QCOMPARE(editWidget->inputMethodHints(), dialog.inputMethodHints()); + QCOMPARE(editWidget->inputMethodHints(), Qt::ImhDigitsOnly); +} + QTEST_MAIN(tst_QInputDialog) #include "tst_qinputdialog.moc" -- cgit v0.12