From 2ffcf454806d0167c36bb626f07c3cc969206709 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 11 Sep 2009 10:18:12 +0200 Subject: Clean up properly in the QPF1 font engine We have to munmap() what we have mmap()ed Reviewed-by: Gunnar Reviewed-by: Jeremy --- src/gui/text/qfontengine_qws.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gui/text/qfontengine_qws.cpp b/src/gui/text/qfontengine_qws.cpp index 0c988e0..730fc2c 100644 --- a/src/gui/text/qfontengine_qws.cpp +++ b/src/gui/text/qfontengine_qws.cpp @@ -380,6 +380,8 @@ class QFontEngineQPF1Data public: QPFFontMetrics fm; QPFGlyphTree *tree; + void *mmapStart; + size_t mmapLength; }; @@ -409,6 +411,8 @@ QFontEngineQPF1::QFontEngineQPF1(const QFontDef&, const QString &fn) ::close(f); d = new QFontEngineQPF1Data; + d->mmapStart = data; + d->mmapLength = st.st_size; memcpy(reinterpret_cast(&d->fm),data,sizeof(d->fm)); data += sizeof(d->fm); @@ -430,6 +434,8 @@ QFontEngineQPF1::QFontEngineQPF1(const QFontDef&, const QString &fn) QFontEngineQPF1::~QFontEngineQPF1() { + if (d->mmapStart) + munmap(d->mmapStart, d->mmapLength); delete d->tree; delete d; } -- cgit v0.12 From f1710803cc17a50d098e945e86ad75d42b036935 Mon Sep 17 00:00:00 2001 From: Thomas Sondergaard Date: Mon, 14 Sep 2009 14:33:39 +0200 Subject: Fixed off-by-one error in call to XGetKeyboardMapping that meant that max_keycode wasn't retrieved. Merge-request: 1308 Reviewed-by: Oswald Buddenhagen --- src/gui/kernel/qkeymapper_x11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qkeymapper_x11.cpp b/src/gui/kernel/qkeymapper_x11.cpp index 488cc6a..0ce77fe 100644 --- a/src/gui/kernel/qkeymapper_x11.cpp +++ b/src/gui/kernel/qkeymapper_x11.cpp @@ -536,7 +536,7 @@ void QKeyMapperPrivate::clearMappings() coreDesc.keysyms_per_keycode = 0; coreDesc.keysyms = XGetKeyboardMapping(X11->display, coreDesc.min_keycode, - coreDesc.max_keycode - coreDesc.min_keycode, + coreDesc.max_keycode - coreDesc.min_keycode + 1, &coreDesc.keysyms_per_keycode); #if 0 -- cgit v0.12 From b2d7bcf1e77e8b9bc8fc1b40777907d7a8d47c09 Mon Sep 17 00:00:00 2001 From: Bill King Date: Mon, 14 Sep 2009 16:39:26 +1000 Subject: Fixes crash when calling numRows on unknown query type (ibase) Reviewed-by: Justin McPherson --- src/sql/drivers/ibase/qsql_ibase.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sql/drivers/ibase/qsql_ibase.cpp b/src/sql/drivers/ibase/qsql_ibase.cpp index bde3930..7a4609d 100644 --- a/src/sql/drivers/ibase/qsql_ibase.cpp +++ b/src/sql/drivers/ibase/qsql_ibase.cpp @@ -1262,6 +1262,9 @@ int QIBaseResult::numRowsAffected() case isc_info_sql_stmt_insert: cCountType = isc_info_req_insert_count; break; + default: + qWarning() << "numRowsAffected: Unknown statement type (" << d->queryType << ")"; + return -1; } char acBuffer[33]; -- cgit v0.12 From e6f191185d0a80ced3434a8b378b139386c43760 Mon Sep 17 00:00:00 2001 From: Bill King Date: Mon, 14 Sep 2009 16:45:26 +1000 Subject: Fixes QSqlTableModel: trying to delete the wrong row. Uses the primary key from the index in the query, not the resulting location in the modified dataset. Task-number: 222678 --- src/sql/models/qsqltablemodel.cpp | 9 ++-- tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp | 61 ++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 4 deletions(-) diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp index a532449..a91dc9f 100644 --- a/src/sql/models/qsqltablemodel.cpp +++ b/src/sql/models/qsqltablemodel.cpp @@ -559,7 +559,7 @@ bool QSqlTableModel::setData(const QModelIndex &index, const QVariant &value, in if (row.op == QSqlTableModelPrivate::None) { row.op = QSqlTableModelPrivate::Update; row.rec = d->rec; - row.primaryValues = d->primaryValues(indexInQuery(index).row()); + row.primaryValues = d->primaryValues(indexInQuery(index).row()); } row.rec.setValue(index.column(), value); emit dataChanged(index, index); @@ -669,7 +669,7 @@ bool QSqlTableModel::deleteRowFromTable(int row) Q_D(QSqlTableModel); emit beforeDelete(row); - QSqlRecord rec = d->primaryValues(row); + const QSqlRecord whereValues = d->strategy == OnManualSubmit ? d->cache[row].primaryValues : d->primaryValues(row); bool prepStatement = d->db.driver()->hasFeature(QSqlDriver::PreparedQueries); QString stmt = d->db.driver()->sqlStatement(QSqlDriver::DeleteStatement, d->tableName, @@ -677,7 +677,7 @@ bool QSqlTableModel::deleteRowFromTable(int row) prepStatement); QString where = d->db.driver()->sqlStatement(QSqlDriver::WhereStatement, d->tableName, - rec, + whereValues, prepStatement); if (stmt.isEmpty() || where.isEmpty()) { @@ -687,7 +687,7 @@ bool QSqlTableModel::deleteRowFromTable(int row) } stmt.append(QLatin1Char(' ')).append(where); - return d->exec(stmt, prepStatement, rec); + return d->exec(stmt, prepStatement, whereValues); } /*! @@ -1097,6 +1097,7 @@ bool QSqlTableModel::removeRows(int row, int count, const QModelIndex &parent) revertRow(idx); else { d->cache[idx].op = QSqlTableModelPrivate::Delete; + d->cache[idx].primaryValues = d->primaryValues(indexInQuery(createIndex(idx, 0)).row()); emit headerDataChanged(Qt::Vertical, idx, idx); } } diff --git a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp index 15fe686..0369e86 100644 --- a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp +++ b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp @@ -119,6 +119,11 @@ private slots: void tableModifyWithBlank_data() { generic_data(); } void tableModifyWithBlank(); // For mail task + void removeColumnAndRow_data() { generic_data(); } + void removeColumnAndRow(); // task 256032 + + void insertBeforeDelete_data() { generic_data(); } + void insertBeforeDelete(); private: void generic_data(const QString& engine=QString()); }; @@ -985,5 +990,61 @@ void tst_QSqlTableModel::tableModifyWithBlank() QCOMPARE(model.record(0).value(1).toString(), QLatin1String("col1ModelData")); } +void tst_QSqlTableModel::removeColumnAndRow() +{ + QFETCH(QString, dbName); + QSqlDatabase db = QSqlDatabase::database(dbName); + CHECK_DATABASE(db); + + QSqlTableModel model(0, db); + model.setTable(qTableName("test")); + model.setEditStrategy(QSqlTableModel::OnManualSubmit); + QVERIFY_SQL(model, select()); + QCOMPARE(model.rowCount(), 3); + QCOMPARE(model.columnCount(), 3); + + QVERIFY(model.removeColumn(0)); + QVERIFY(model.removeRow(0)); + QVERIFY(model.submitAll()); + QCOMPARE(model.rowCount(), 2); + QCOMPARE(model.columnCount(), 2); + + // check with another table because the model has been modified + // but not the sql table + QSqlTableModel model2(0, db); + model2.setTable(qTableName("test")); + QVERIFY_SQL(model2, select()); + QCOMPARE(model2.rowCount(), 2); + QCOMPARE(model2.columnCount(), 3); +} + +void tst_QSqlTableModel::insertBeforeDelete() +{ + QFETCH(QString, dbName); + QSqlDatabase db = QSqlDatabase::database(dbName); + CHECK_DATABASE(db); + + QSqlQuery q(db); + QVERIFY_SQL( q, exec("insert into " + qTableName("test") + " values(9, 'andrew', 9)")); + QVERIFY_SQL( q, exec("insert into " + qTableName("test") + " values(10, 'justin', 10)")); + + QSqlTableModel model(0, db); + model.setTable(qTableName("test")); + model.setEditStrategy(QSqlTableModel::OnManualSubmit); + QVERIFY_SQL(model, select()); + + qDebug() << model.rowCount(); + + QSqlRecord rec = model.record(); + rec.setValue(0, 4); + rec.setValue(1, QString("bill")); + rec.setValue(2, 4); + QVERIFY_SQL(model, insertRecord(4, rec)); + + QVERIFY_SQL(model, removeRow(5)); + QVERIFY_SQL(model, submitAll()); + QCOMPARE(model.rowCount(), 5); +} + QTEST_MAIN(tst_QSqlTableModel) #include "tst_qsqltablemodel.moc" -- cgit v0.12 From 72fc24222ab7f89dc9e606e315ebfb134ba157a8 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 15 Sep 2009 15:22:10 +0200 Subject: Fix drawing text in QPicture and printing in right-to-left mode Change 979d1d3bbc0c68789edbe93f03464d41d7a8469a requires qt_format_text() to honor the Qt::TextForceLeftToRight flag. Without this, the text will be laid out RTL twice, and the output will be broken. Since printing is done through QPicture, this fixes printing when the UI is reversed. Task-number: 261033 Reviewed-by: Trond --- src/gui/painting/qpainter.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 358e856..97f3dd4 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -7469,7 +7469,11 @@ void qt_format_text(const QFont &fnt, const QRectF &_r, bool hidemnmemonic = (tf & Qt::TextHideMnemonic); Qt::LayoutDirection layout_direction; - if(option) + if (tf & Qt::TextForceLeftToRight) + layout_direction = Qt::LeftToRight; + else if (tf & Qt::TextForceRightToLeft) + layout_direction = Qt::RightToLeft; + else if (option) layout_direction = option->textDirection(); else if (painter) layout_direction = painter->layoutDirection(); -- cgit v0.12 From e7042dea2431b8f64574d4e97eb896285b328c8b Mon Sep 17 00:00:00 2001 From: andyc Date: Fri, 3 Jul 2009 17:25:25 -0400 Subject: Added autotest to demonstrate clipping path problem --- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 32 ++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index d6605db..391ccf8 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -194,6 +194,7 @@ private slots: void itemClipsToShape(); void itemClipsChildrenToShape(); void itemClipsChildrenToShape2(); + void itemClipsChildrenToShape3(); void itemClipsTextChildToShape(); void itemClippingDiscovery(); void ancestorFlags(); @@ -4691,6 +4692,37 @@ void tst_QGraphicsItem::itemClipsChildrenToShape2() #endif } +void tst_QGraphicsItem::itemClipsChildrenToShape3() +{ + // Construct a scene with nested children, each 50 pixels offset from the elder. + // Set a top-level clipping flag + QGraphicsScene scene; + QGraphicsRectItem *parent = scene.addRect( 0, 0, 150, 150 ); + QGraphicsRectItem *child = scene.addRect( 0, 0, 150, 150 ); + QGraphicsRectItem *grandchild = scene.addRect( 0, 0, 150, 150 ); + child->setParentItem(parent); + grandchild->setParentItem(child); + child->setPos( 50, 50 ); + grandchild->setPos( 50, 50 ); + parent->setFlag(QGraphicsItem::ItemClipsChildrenToShape); + + QCOMPARE(scene.itemAt(25,25), (QGraphicsItem *)parent); + QCOMPARE(scene.itemAt(75,75), (QGraphicsItem *)child); + QCOMPARE(scene.itemAt(125,125), (QGraphicsItem *)grandchild); + QCOMPARE(scene.itemAt(175,175), (QGraphicsItem *)0); + + // Move child to fully overlap the parent. The grandchild should + // now occupy two-thirds of the scene + child->prepareGeometryChange(); + child->setPos( 0, 0 ); + + QCOMPARE(scene.itemAt(25,25), (QGraphicsItem *)child); + QCOMPARE(scene.itemAt(75,75), (QGraphicsItem *)grandchild); + QCOMPARE(scene.itemAt(125,125), (QGraphicsItem *)grandchild); + QCOMPARE(scene.itemAt(175,175), (QGraphicsItem *)0); +} + + void tst_QGraphicsItem::itemClipsTextChildToShape() { // Construct a scene with a rect that clips its children, with one text -- cgit v0.12 From 6a0ccd3477b0ddb0a550b56bdc41e8ae1cf740a6 Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Wed, 16 Sep 2009 16:55:29 +1000 Subject: Fixes: Fixed incorrect tracks number calculation with phonon/gst RevBy: Andrew den Exter Details: gst_element_query_duration(element,format,duration) doesn't always return duration in format being asked for (tracks in this case), it can also return duration in format it can (Time) and modify format parameter, so check the format is still the same as requested is necessary. This bug prevented Phonon to emit finished() signal with some files, since it expected next tracks to exist. --- src/3rdparty/phonon/gstreamer/mediaobject.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/3rdparty/phonon/gstreamer/mediaobject.cpp b/src/3rdparty/phonon/gstreamer/mediaobject.cpp index 74fc1b4..13f9734 100644 --- a/src/3rdparty/phonon/gstreamer/mediaobject.cpp +++ b/src/3rdparty/phonon/gstreamer/mediaobject.cpp @@ -965,11 +965,15 @@ void MediaObject::getStreamInfo() gint64 titleCount; GstFormat format = gst_format_get_by_nick("track"); if (gst_element_query_duration (m_pipeline, &format, &titleCount)) { - int oldAvailableTitles = m_availableTitles; - m_availableTitles = (int)titleCount; - if (m_availableTitles != oldAvailableTitles) { - emit availableTitlesChanged(m_availableTitles); - m_backend->logMessage(QString("Available titles changed: %0").arg(m_availableTitles), Backend::Info, this); + //check if returned format is still "track", + //gstreamer sometimes returns the total time, if tracks information is not available. + if (qstrcmp(gst_format_get_name(format), "track") == 0) { + int oldAvailableTitles = m_availableTitles; + m_availableTitles = (int)titleCount; + if (m_availableTitles != oldAvailableTitles) { + emit availableTitlesChanged(m_availableTitles); + m_backend->logMessage(QString("Available titles changed: %0").arg(m_availableTitles), Backend::Info, this); + } } } -- cgit v0.12