From ad68c845e3e368dc4235e64b54e15a9ee886b078 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Thu, 9 Dec 2010 14:25:16 +0200 Subject: QLabel wraps text at fixed lengths There are multiple problems with text wrapping and dialogs. First, teh CBA height was assumed to be zero, or fetch from previous layout, which caused the dialog to be half under the CBA. Now, CBA height is always asked from AVKON metrics, since asking it from actual component might fail (or produce incorrect results) due to that the component is not created yet (or might still have previous layout active). Additionally, qinputDialog label is now having a size policy to restrict its growing out of dialog borders. Task-number: QT-4354 Reviewed-by: Janne Koskinen --- src/gui/dialogs/qdialog.cpp | 13 ++++++------- src/gui/dialogs/qinputdialog.cpp | 2 ++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/gui/dialogs/qdialog.cpp b/src/gui/dialogs/qdialog.cpp index fbdc522..16ea045 100644 --- a/src/gui/dialogs/qdialog.cpp +++ b/src/gui/dialogs/qdialog.cpp @@ -901,15 +901,13 @@ bool QDialog::symbianAdjustedPosition() QPoint p; const bool doS60Positioning = !(isFullScreen()||isMaximized()); if (doS60Positioning) { + QPoint oldPos = pos(); // naive way to deduce screen orientation if (S60->screenHeightInPixels > S60->screenWidthInPixels) { int cbaHeight; - const CEikButtonGroupContainer* bgContainer = S60->buttonGroupContainer(); - if (!bgContainer) { - cbaHeight = 0; - } else { - cbaHeight = qt_TSize2QSize(bgContainer->Size()).height(); - } + TRect rect; + AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EControlPane, rect); + cbaHeight = rect.Height(); p.setY(S60->screenHeightInPixels - height() - cbaHeight); p.setX(0); } else { @@ -939,7 +937,8 @@ bool QDialog::symbianAdjustedPosition() p.setX(qMax(0,S60->screenWidthInPixels - width())); } } - move(p); + if (oldPos != p || p.y() < 0) + move(p); } return doS60Positioning; #else diff --git a/src/gui/dialogs/qinputdialog.cpp b/src/gui/dialogs/qinputdialog.cpp index ce27bd3..a29376a 100644 --- a/src/gui/dialogs/qinputdialog.cpp +++ b/src/gui/dialogs/qinputdialog.cpp @@ -234,6 +234,8 @@ void QInputDialogPrivate::ensureLayout() //we want to let the input dialog grow to available size on Symbian. #ifndef Q_OS_SYMBIAN mainLayout->setSizeConstraint(QLayout::SetMinAndMaxSize); +#else + label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); #endif mainLayout->addWidget(label); mainLayout->addWidget(inputWidget); -- cgit v0.12 From 9d8dac4e4509795b6af8a5885f6e9f1a3ccbaa06 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Fri, 10 Dec 2010 11:12:23 +0200 Subject: QDateTimeEdit is not showing correctly when resizes in symbian The problem boils down to using large square area for QDateTime widget (which is more or less a date-aware combobox). Style tries to make the combobox button as wide as it is tall, and as button is as tall as the combobox frame, it steals the whole square widget for itself. To fix this, we now limit the combobox button height to be no more than fourth of the total width of the widget. Thus, in normal, non-resized case, button is, as tall as the frame, but as widget is made larger, button stops to grow after reaching quarter of width of the widget. Task-number: QT-4312 Reviewed-by: Janne Koskinen --- src/gui/styles/qs60style.cpp | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 2f09529..3c715b7 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -104,11 +104,11 @@ const int QS60StylePrivate::m_numberOfLayouts = const short QS60StylePrivate::data[][MAX_PIXELMETRICS] = { // *** generated pixel metrics *** -{5,0,-909,0,0,2,0,0,-1,7,12,22,15,15,7,198,-909,-909,-909,20,13,2,0,0,21,7,18,30,3,3,1,-909,-909,0,1,0,0,12,20,15,15,18,18,1,115,18,0,-909,-909,-909,-909,0,0,16,2,-909,0,0,-909,16,-909,-909,-909,-909,32,18,55,24,55,4,4,4,9,13,-909,5,51,11,5,0,3,3,6,8,3,3,-909,2,-909,-909,-909,-909,5,5,3,1,106}, -{5,0,-909,0,0,1,0,0,-1,8,14,22,15,15,7,164,-909,-909,-909,19,15,2,0,0,21,8,27,28,4,4,1,-909,-909,0,7,6,0,13,23,17,17,21,21,7,115,21,0,-909,-909,-909,-909,0,0,15,1,-909,0,0,-909,15,-909,-909,-909,-909,32,21,65,27,65,3,3,5,10,15,-909,5,58,13,5,0,4,4,7,9,4,4,-909,2,-909,-909,-909,-909,6,6,3,1,106}, -{7,0,-909,0,0,2,0,0,-1,25,69,46,37,37,9,258,-909,-909,-909,23,19,26,0,0,32,25,72,44,5,5,2,-909,-909,0,7,21,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,25,2,-909,0,0,-909,25,-909,-909,-909,-909,87,27,77,35,77,13,3,6,8,19,-909,7,74,19,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1,135}, -{7,0,-909,0,0,2,0,0,-1,25,68,46,37,37,9,258,-909,-909,-909,31,19,6,0,0,32,25,60,52,5,5,2,-909,-909,0,7,32,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,26,2,-909,0,0,-909,26,-909,-909,-909,-909,87,27,96,35,96,12,3,6,8,19,-909,7,74,22,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1,135}, -{7,0,-909,0,0,2,0,0,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,7,32,30,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,6,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,5,6,8,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1,106} +{5,0,-909,0,0,2,0,2,-1,7,12,22,15,15,7,198,-909,-909,-909,20,13,2,0,0,21,7,18,30,3,3,1,-909,-909,0,1,0,0,12,20,15,15,18,18,1,115,18,0,-909,-909,-909,-909,0,0,16,2,-909,0,0,-909,16,-909,-909,-909,-909,32,18,55,24,55,4,4,4,9,13,-909,5,51,11,5,0,3,3,6,8,3,3,-909,2,-909,-909,-909,-909,5,5,3,1,106}, +{5,0,-909,0,0,1,0,2,-1,8,14,22,15,15,7,164,-909,-909,-909,19,15,2,0,0,21,8,27,28,4,4,1,-909,-909,0,7,6,0,13,23,17,17,21,21,7,115,21,0,-909,-909,-909,-909,0,0,15,1,-909,0,0,-909,15,-909,-909,-909,-909,32,21,65,27,65,3,3,5,10,15,-909,5,58,13,5,0,4,4,7,9,4,4,-909,2,-909,-909,-909,-909,6,6,3,1,106}, +{7,0,-909,0,0,2,0,5,-1,25,69,46,37,37,9,258,-909,-909,-909,23,19,26,0,0,32,25,72,44,5,5,2,-909,-909,0,7,21,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,25,2,-909,0,0,-909,25,-909,-909,-909,-909,87,27,77,35,77,13,3,6,8,19,-909,7,74,19,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1,135}, +{7,0,-909,0,0,2,0,5,-1,25,68,46,37,37,9,258,-909,-909,-909,31,19,6,0,0,32,25,60,52,5,5,2,-909,-909,0,7,32,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,26,2,-909,0,0,-909,26,-909,-909,-909,-909,87,27,96,35,96,12,3,6,8,19,-909,7,74,22,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1,135}, +{7,0,-909,0,0,2,0,2,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,7,32,30,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,6,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,5,6,8,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1,106} // *** End of generated data *** }; @@ -1071,11 +1071,11 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom // Button frame QStyleOptionFrame buttonOption; buttonOption.QStyleOption::operator=(*cmb); - const int maxHeight = cmbxFrame.height(); - const int maxWidth = cmbxFrame.width() - cmbxEditField.width(); + const int maxButtonSide = cmbxFrame.width() - cmbxEditField.width(); + const int newTop = cmbxEditField.center().y() - maxButtonSide / 2; const int topLeftPoint = direction ? - (cmbxEditField.right() + 1) : (cmbxEditField.left() + 1 - maxWidth); - const QRect buttonRect(topLeftPoint, cmbxEditField.top(), maxWidth, maxHeight); + (cmbxEditField.right() + 1) : (cmbxEditField.left() + 1 - maxButtonSide); + const QRect buttonRect(topLeftPoint, newTop, maxButtonSide, maxButtonSide); buttonOption.rect = buttonRect; buttonOption.state = cmb->state; drawPrimitive(PE_PanelButtonCommand, &buttonOption, painter, widget); @@ -2884,30 +2884,24 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple ret = cmb->rect; const int width = cmb->rect.width(); const int height = cmb->rect.height(); - const int buttonIconSize = QS60StylePrivate::pixelMetric(PM_ButtonIconSize); const int buttonMargin = cmb->frame ? 2 : 0; // lets use spinbox frame here as well, as no combobox specific value available. const int frameThickness = cmb->frame ? pixelMetric(PM_SpinBoxFrameWidth, cmb, widget) : 0; - const int buttonWidth = qMax(cmb->rect.height(), buttonIconSize); - + const int buttonMinSize = QS60StylePrivate::pixelMetric(PM_ButtonIconSize) + 2 * buttonMargin; QSize buttonSize; - buttonSize.setWidth(buttonWidth + 2 * buttonMargin); - buttonSize.setHeight(qMax(8, (cmb->rect.height() >> 1) - frameThickness)); //buttons should be squares + //allow button to grow to one fourth of the frame height, if the frame is really tall + buttonSize.setHeight(qMin(height, qMax(width / 4, buttonMinSize))); + buttonSize.setWidth(buttonSize.height()); buttonSize = buttonSize.expandedTo(QApplication::globalStrut()); switch (scontrol) { case SC_ComboBoxArrow: { - const int xposMod = cmb->rect.x() + width - buttonMargin - buttonWidth; + const int xposMod = cmb->rect.x() + width - buttonMargin - buttonSize.width(); const int ypos = cmb->rect.y(); - ret.setRect(xposMod, ypos + buttonMargin, buttonWidth, height - 2 * buttonMargin); + ret.setRect(xposMod, ypos + buttonMargin, buttonSize.width(), height - 2 * buttonMargin); } break; case SC_ComboBoxEditField: { - const int withFrameX = cmb->rect.x() + width - frameThickness - buttonSize.width(); - ret = QRect( - frameThickness, - frameThickness, - withFrameX - frameThickness, - height - 2 * frameThickness); + ret = QRect(0, 0, cmb->rect.x() + width - buttonSize.width(), height); } break; case SC_ComboBoxListBoxPopup: { -- cgit v0.12 From f2ab8acd583941dcd673c627ff03d25e519e1f6b Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Fri, 10 Dec 2010 11:34:45 +0200 Subject: Fix whitespace in qs60style.cpp Reviewed-by: TrustMe --- src/gui/styles/qs60style.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 3c715b7..56d2d19 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -2889,7 +2889,7 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple const int frameThickness = cmb->frame ? pixelMetric(PM_SpinBoxFrameWidth, cmb, widget) : 0; const int buttonMinSize = QS60StylePrivate::pixelMetric(PM_ButtonIconSize) + 2 * buttonMargin; QSize buttonSize; - //allow button to grow to one fourth of the frame height, if the frame is really tall + //allow button to grow to one fourth of the frame height, if the frame is really tall buttonSize.setHeight(qMin(height, qMax(width / 4, buttonMinSize))); buttonSize.setWidth(buttonSize.height()); buttonSize = buttonSize.expandedTo(QApplication::globalStrut()); -- cgit v0.12 From 6160f8541e4d7cb66de7680b5fb439fb757c59dd Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Mon, 13 Dec 2010 10:28:42 +0200 Subject: Symbian specific input methods should use 'Text' mode as default case Currently default case is 'lower'. It makes more sense to set the default as 'Text', as it is natural default case for most text entries. Task-number: QTBUG-10311 Reviewed-by: Miikka Heikkinen --- src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index 4a1b9b9..5e8a2e1 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -89,7 +89,7 @@ QCoeFepInputContext::QCoeFepInputContext(QObject *parent) m_fepState->SetFlags(EAknEditorFlagDefault); m_fepState->SetDefaultInputMode( EAknEditorTextInputMode ); m_fepState->SetPermittedInputModes( EAknEditorAllInputModes ); - m_fepState->SetDefaultCase( EAknEditorLowerCase ); + m_fepState->SetDefaultCase( EAknEditorTextCase ); m_fepState->SetPermittedCases( EAknEditorAllCaseModes ); m_fepState->SetSpecialCharacterTableResourceId(R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG); m_fepState->SetNumericKeymap( EAknEditorStandardNumberModeKeymap ); -- cgit v0.12 From 7ee2e9fd873b2c38a1a362170c4a0e4754cfd22a Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 18 Oct 2010 09:28:14 +0200 Subject: Cocoa: native child filedialogs sometimes shows non-native on screen The reason is that we make all child dialogs of a modal dialogs non-modaly shaddowed, as documented. But we forgot to check if a window is actually visible before raising it to front. Also adding harmless auto release pool Rev-By: prasanth --- src/gui/kernel/qeventdispatcher_mac.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qeventdispatcher_mac.mm b/src/gui/kernel/qeventdispatcher_mac.mm index 515c6d3..dc926e0 100644 --- a/src/gui/kernel/qeventdispatcher_mac.mm +++ b/src/gui/kernel/qeventdispatcher_mac.mm @@ -844,7 +844,7 @@ static void setChildrenWorksWhenModal(QWidget *widget, bool worksWhenModal) NSWindow *window = qt_mac_window_for(dialogs[i]); if (window && [window isKindOfClass:[NSPanel class]]) { [static_cast(window) setWorksWhenModal:worksWhenModal]; - if (worksWhenModal && dialogs[i]->isVisible()){ + if (worksWhenModal && [window isVisible]){ [window orderFront:window]; } } @@ -856,6 +856,7 @@ void QEventDispatcherMacPrivate::updateChildrenWorksWhenModal() // Make the dialog children of the widget // active. And make the dialog children of // the previous modal dialog unactive again: + QMacCocoaAutoReleasePool pool; int size = cocoaModalSessionStack.size(); if (size > 0){ if (QWidget *prevModal = cocoaModalSessionStack[size-1].widget) -- cgit v0.12 From a04b19d34c23df5bb6e4f499b6b12c7a1211969a Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 18 Oct 2010 15:27:02 +0200 Subject: Cocoa: make sure stays on top child windows are not levelled down [NSWindow addChild] levels the child to the level of the parent. In Qt we do not want this. So we do a check after setting up the parent-child relationship for this. Reviewed-by: cduclos --- src/gui/kernel/qwidget_mac.mm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 997419b..08af3ac 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -2822,8 +2822,12 @@ void QWidgetPrivate::setSubWindowStacking(bool set) if (NSWindow *pwin = [qt_mac_nativeview_for(parent) window]) { if (set) { Qt::WindowType ptype = parent->window()->windowType(); - if ([pwin isVisible] && (ptype == Qt::Window || ptype == Qt::Dialog) && ![qwin parentWindow]) + if ([pwin isVisible] && (ptype == Qt::Window || ptype == Qt::Dialog) && ![qwin parentWindow]) { + NSInteger level = [qwin level]; [pwin addChildWindow:qwin ordered:NSWindowAbove]; + if ([qwin level] < level) + [qwin setLevel:level]; + } } else { [pwin removeChildWindow:qwin]; } @@ -2837,8 +2841,12 @@ void QWidgetPrivate::setSubWindowStacking(bool set) if (NSWindow *cwin = [qt_mac_nativeview_for(child) window]) { if (set) { Qt::WindowType ctype = child->window()->windowType(); - if ([cwin isVisible] && (ctype == Qt::Window || ctype == Qt::Dialog) && ![cwin parentWindow]) + if ([cwin isVisible] && (ctype == Qt::Window || ctype == Qt::Dialog) && ![cwin parentWindow]) { + NSInteger level = [cwin level]; [qwin addChildWindow:cwin ordered:NSWindowAbove]; + if ([cwin level] < level) + [cwin setLevel:level]; + } } else { [qwin removeChildWindow:qt_mac_window_for(child)]; } -- cgit v0.12 From 19148694b1e094ad968e26e6fab448d3d2c7f4d4 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 18 Oct 2010 15:30:12 +0200 Subject: Cocoa: cannot use staysOnTop flag for native file dialogs We cannot mix staysOnTop and native file dialogs, since Cocoa will anyway set it back to NSModalPanelWindowLevel when running it app modal. There are ways to work around this issue, but the file dialog also has a button for showing a "create directory" modal panel, and this we cannot control. Reviewed-by: cduclos --- src/gui/dialogs/qfiledialog_mac.mm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gui/dialogs/qfiledialog_mac.mm b/src/gui/dialogs/qfiledialog_mac.mm index 87850a7..1e13113 100644 --- a/src/gui/dialogs/qfiledialog_mac.mm +++ b/src/gui/dialogs/qfiledialog_mac.mm @@ -719,6 +719,14 @@ bool QFileDialogPrivate::setVisible_sys(bool visible) if (!visible == q->isHidden()) return false; + if (q->windowFlags() & Qt::WindowStaysOnTopHint) { + // The native file dialog tries all it can to stay + // on the NSModalPanel level. And it might also show + // its own "create directory" dialog that we cannot control. + // So we need to use the non-native version in this case... + return false; + } + #ifndef QT_MAC_USE_COCOA return visible ? showCarbonNavServicesDialog() : hideCarbonNavServicesDialog(); #else -- cgit v0.12 From 3e2cb226277998a7841c85048493c89bc1ccc95f Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 18 Oct 2010 16:12:46 +0200 Subject: Cocoa: Fix addChildWindow bug where we connect a grandparent to a child A plain bug where we ask for a list of widgets, but forget that qFindChildren is recursive, which is not what we want. Reviewed-by: jbache --- src/gui/kernel/qwidget_mac.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 08af3ac..b89cb88 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -2834,9 +2834,9 @@ void QWidgetPrivate::setSubWindowStacking(bool set) } } - QList widgets = q->findChildren(); + QObjectList widgets = q->children(); for (int i=0; i(widgets.at(i)); if (child && child->isWindow()) { if (NSWindow *cwin = [qt_mac_nativeview_for(child) window]) { if (set) { -- cgit v0.12 From 780b4d84205f16c46f6c5e85e6c1925beb4e4dba Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 22 Nov 2010 11:08:34 +0100 Subject: Cocoa: combobox does not hightlight when mouse re-hovers the first item The reason is that on Mac, the highlight is supposed to switch off when the mouse moves out of the drop down menu. On X11, it stays. So there is a separate code path for this in qcombobox.cpp. But it fails to clear the index set in the view when the mouse leaves, which stops the item from re-highligh when the mouse re-enters. Reviewed-by: ogoffart --- src/gui/widgets/qcombobox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index 7859bdc..5a4e507 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -398,7 +398,7 @@ void QComboBoxPrivateContainer::leaveEvent(QEvent *) #ifdef Q_WS_MAC QStyleOptionComboBox opt = comboStyleOption(); if (combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo)) - view->clearSelection(); + view->setCurrentIndex(QModelIndex()); #endif } -- cgit v0.12 From d9004ddf237a09f3b7f25128ceb83a0e79e7b1aa Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 13 Dec 2010 13:39:34 +0100 Subject: Cocoa: popup hides behind window Reason: when cocoa receives a mouse press/release in a window, it finds the correct view inside that window and sends the mouse event to it. But NSWindow also does some other stuff just before sending the event, like raise and lower windows. So when we override sendEvent, and more over, do not call [super sendEvent], we stop this raise/lower etc from working. So, to make this work again, I partially revert change 0b2eab87ad3bd73a0744469a45c29ca098649c9b Task-number: QTBUG-15638, QTBUG-1517 Reviewed-by: Fabien Freling --- src/gui/kernel/qcocoasharedwindowmethods_mac_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h index ddf1a27..1e2e71b 100644 --- a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h +++ b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h @@ -182,7 +182,7 @@ QT_END_NAMESPACE bool handled = false; // sometimes need to redirect mouse events to the popup. QWidget *popup = qAppInstance()->activePopupWidget(); - if (popup) { + if (popup && popup != widget) { switch([event type]) { case NSLeftMouseDown: -- cgit v0.12 From 69ed34d2aa77a3bacc7f66797baa514f35358b7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 13 Dec 2010 14:21:39 +0100 Subject: Fixed GL 2 engine rendering of images / pixmaps above max texture size. Down-scale images or pixmaps that are above the max texture size. Not optimal performance-wise, but better than failing. Task-number: QTBUG-16033 Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 52 +++++++++++++++++++--- .../gl2paintengineex/qpaintengineex_opengl2_p.h | 2 + 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 4a64f39..668a3f0 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -163,6 +163,8 @@ void QGL2PaintEngineExPrivate::setBrush(const QBrush& brush) Q_ASSERT(newStyle != Qt::NoBrush); currentBrush = brush; + if (!currentBrushPixmap.isNull()) + currentBrushPixmap = QPixmap(); brushUniformsDirty = true; // All brushes have at least one uniform if (newStyle > Qt::SolidPattern) @@ -221,10 +223,14 @@ void QGL2PaintEngineExPrivate::updateBrushTexture() updateTextureFilter(GL_TEXTURE_2D, GL_CLAMP_TO_EDGE, q->state()->renderHints & QPainter::SmoothPixmapTransform); } else if (style == Qt::TexturePattern) { - const QPixmap& texPixmap = currentBrush.texture(); + currentBrushPixmap = currentBrush.texture(); + + int max_texture_size = ctx->d_func()->maxTextureSize(); + if (currentBrushPixmap.width() > max_texture_size || currentBrushPixmap.height() > max_texture_size) + currentBrushPixmap = currentBrushPixmap.scaled(max_texture_size, max_texture_size, Qt::KeepAspectRatio); glActiveTexture(GL_TEXTURE0 + QT_BRUSH_TEXTURE_UNIT); - QGLTexture *tex = ctx->d_func()->bindTexture(texPixmap, GL_TEXTURE_2D, GL_RGBA, + QGLTexture *tex = ctx->d_func()->bindTexture(currentBrushPixmap, GL_TEXTURE_2D, GL_RGBA, QGLContext::InternalBindOption | QGLContext::CanFlipNativePixmapBindOption); updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, q->state()->renderHints & QPainter::SmoothPixmapTransform); @@ -1305,13 +1311,30 @@ void QGL2PaintEngineEx::transformChanged() } +static const QRectF scaleRect(const QRectF &r, qreal sx, qreal sy) +{ + return QRectF(r.x() * sx, r.y() * sy, r.width() * sx, r.height() * sy); +} + void QGL2PaintEngineEx::drawPixmap(const QRectF& dest, const QPixmap & pixmap, const QRectF & src) { Q_D(QGL2PaintEngineEx); + QGLContext *ctx = d->ctx; + + int max_texture_size = ctx->d_func()->maxTextureSize(); + if (pixmap.width() > max_texture_size || pixmap.height() > max_texture_size) { + QPixmap scaled = pixmap.scaled(max_texture_size, max_texture_size, Qt::KeepAspectRatio); + + const qreal sx = scaled.width() / qreal(pixmap.width()); + const qreal sy = scaled.height() / qreal(pixmap.height()); + + drawPixmap(dest, scaled, scaleRect(src, sx, sy)); + return; + } + ensureActive(); d->transferMode(ImageDrawingMode); - QGLContext *ctx = d->ctx; glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT); QGLTexture *texture = ctx->d_func()->bindTexture(pixmap, GL_TEXTURE_2D, GL_RGBA, @@ -1334,11 +1357,24 @@ void QGL2PaintEngineEx::drawImage(const QRectF& dest, const QImage& image, const Qt::ImageConversionFlags) { Q_D(QGL2PaintEngineEx); + QGLContext *ctx = d->ctx; + + int max_texture_size = ctx->d_func()->maxTextureSize(); + if (image.width() > max_texture_size || image.height() > max_texture_size) { + QImage scaled = image.scaled(max_texture_size, max_texture_size, Qt::KeepAspectRatio); + + const qreal sx = scaled.width() / qreal(image.width()); + const qreal sy = scaled.height() / qreal(image.height()); + + drawImage(dest, scaled, scaleRect(src, sx, sy)); + return; + } + ensureActive(); d->transferMode(ImageDrawingMode); - QGLContext *ctx = d->ctx; glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT); + QGLTexture *texture = ctx->d_func()->bindTexture(image, GL_TEXTURE_2D, GL_RGBA, QGLContext::InternalBindOption); GLuint id = texture->id; @@ -1737,7 +1773,13 @@ void QGL2PaintEngineEx::drawPixmapFragments(const QPainter::PixmapFragment *frag } ensureActive(); - d->drawPixmapFragments(fragments, fragmentCount, pixmap, hints); + int max_texture_size = d->ctx->d_func()->maxTextureSize(); + if (pixmap.width() > max_texture_size || pixmap.height() > max_texture_size) { + QPixmap scaled = pixmap.scaled(max_texture_size, max_texture_size, Qt::KeepAspectRatio); + d->drawPixmapFragments(fragments, fragmentCount, scaled, hints); + } else { + d->drawPixmapFragments(fragments, fragmentCount, pixmap, hints); + } } diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index b255e75..02b737b 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -274,6 +274,8 @@ public: QBrush currentBrush; // May not be the state's brush! const QBrush noBrush; + QPixmap currentBrushPixmap; + QGL2PEXVertexArray vertexCoordinateArray; QGL2PEXVertexArray textureCoordinateArray; QVector elementIndices; -- cgit v0.12 From 0af1f5508e165f3b494ab236cb1cdf1b0edcffa5 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 13 Dec 2010 11:29:22 +0100 Subject: Fixes text jitter in QtQuick components when using the virtual keyboard QGraphicsView::mapFromScene() returns a QRect instead of a QRectF. Thus, we were prematurely rounding the micro focus rectangle coordinates in QGraphicsView::inputMethodQuery(). (The Qt::ImMicroFocus query returns a QRectF from QGraphicsScene, which is the result of querying QDeclarativeTextEdit and mapping it to the scene.) Auto-test included. Reviewed-by: leo Reviewed-by: bnilsen Task-number: QTCOMPONENTS-288 Task-number: QTBUG-16063 --- src/gui/graphicsview/qgraphicsview.cpp | 2 +- tests/auto/qgraphicsview/tst_qgraphicsview.cpp | 39 ++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index a566c8e..2acea8a 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -2494,7 +2494,7 @@ QVariant QGraphicsView::inputMethodQuery(Qt::InputMethodQuery query) const QVariant value = d->scene->inputMethodQuery(query); if (value.type() == QVariant::RectF) - value = mapFromScene(value.toRectF()).boundingRect(); + value = d->mapRectFromScene(value.toRectF()); else if (value.type() == QVariant::PointF) value = mapFromScene(value.toPointF()); else if (value.type() == QVariant::Rect) diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index 0a9633f..e1fbaee 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -246,6 +246,7 @@ private slots: void QTBUG_4151_clipAndIgnore(); void QTBUG_5859_exposedRect(); void QTBUG_7438_cursor(); + void QTBUG_16063_microFocusRect(); public slots: void dummySlot() {} @@ -4450,5 +4451,43 @@ void tst_QGraphicsView::QTBUG_7438_cursor() #endif } +class IMItem : public QGraphicsRectItem +{ +public: + IMItem(QGraphicsItem *parent = 0): + QGraphicsRectItem(mf.adjusted(-5, -5, 5, 5), parent) + { + setFlag(QGraphicsItem::ItemIsFocusable, true); + setFlag(QGraphicsItem::ItemAcceptsInputMethod, true); + } + + QVariant inputMethodQuery(Qt::InputMethodQuery query) const + { + return mf; + } + + static QRectF mf; +}; + +QRectF IMItem::mf(1.5, 1.6, 10, 10); + +void tst_QGraphicsView::QTBUG_16063_microFocusRect() +{ + QGraphicsScene scene; + IMItem *item = new IMItem(); + scene.addItem(item); + + QGraphicsView view(&scene); + + view.setFixedSize(40, 40); + view.show(); + QTest::qWaitForWindowShown(&view); + + scene.setFocusItem(item); + view.setFocus(); + QRectF mfv = view.inputMethodQuery(Qt::ImMicroFocus).toRectF(); + QCOMPARE(mfv, QRectF(13.5, 13.6, 10, 10)); +} + QTEST_MAIN(tst_QGraphicsView) #include "tst_qgraphicsview.moc" -- cgit v0.12 From d5fe82b2ab939727f573429605abd99c039a99d1 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 13 Dec 2010 15:41:16 +0200 Subject: Fix crash when creating more than one QApplication in single test case CBA pointer is stored in static variable and it wasn't cleaned up properly at QApplication destruction, which led to crash. Task-number: QTBUG-15915 Reviewed-by: Sami Merila Reviewed-by: Janne Koskinen --- src/gui/kernel/qapplication_s60.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 8596563..81fa4e6 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -1633,6 +1633,13 @@ void qt_cleanup() //Change mouse pointer back S60->wsSession().SetPointerCursorMode(EPointerCursorNone); +#ifdef Q_WS_S60 + // Clear CBA + CEikonEnv::Static()->AppUiFactory()->SwapButtonGroup(0); + delete S60->buttonGroupContainer(); + S60->setButtonGroupContainer(0); +#endif + if (S60->qtOwnsS60Environment) { // Restore the S60 framework trap handler. See qt_init(). User::SetTrapHandler(S60->s60InstalledTrapHandler); -- cgit v0.12 From 50d3c15bd16f4e70327f8de30c8c0df5ed2f995c Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 13 Dec 2010 16:08:36 +0200 Subject: Minor optimization Use already defined factory pointer instead of re-asking it twice. Reviewed-by: Janne Koskinen --- src/gui/kernel/qwidget_s60.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 609307c..d6ad3c3 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -504,7 +504,7 @@ void QWidgetPrivate::show_sys() CEikButtonGroupContainer *cba = CEikButtonGroupContainer::NewL(CEikButtonGroupContainer::ECba, CEikButtonGroupContainer::EHorizontal,ui,R_AVKON_SOFTKEYS_EMPTY_WITH_IDS); - CEikButtonGroupContainer *oldCba = CEikonEnv::Static()->AppUiFactory()->SwapButtonGroup(cba); + CEikButtonGroupContainer *oldCba = factory->SwapButtonGroup(cba); Q_ASSERT(!oldCba); S60->setButtonGroupContainer(cba); @@ -513,7 +513,7 @@ void QWidgetPrivate::show_sys() menuBar->SetMenuType(CEikMenuBar::EMenuOptions); S60->appUi()->AddToStackL(menuBar,ECoeStackPriorityMenu,ECoeStackFlagRefusesFocus); - CEikMenuBar *oldMenu = CEikonEnv::Static()->AppUiFactory()->SwapMenuBar(menuBar); + CEikMenuBar *oldMenu = factory->SwapMenuBar(menuBar); Q_ASSERT(!oldMenu); ) -- cgit v0.12 From 5e0be0aae4aa4011b4dbf7d1d457e4c8b4f6d4dc Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 13 Dec 2010 16:12:25 +0200 Subject: Fix qapplication autotest deployment Necessary default deployment was getting removed from qapplication test Task-number: QTBUG-15915 Reviewed-by: Janne Koskinen --- tests/auto/qapplication/test/test.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qapplication/test/test.pro b/tests/auto/qapplication/test/test.pro index 2c54c37..d946e7e 100644 --- a/tests/auto/qapplication/test/test.pro +++ b/tests/auto/qapplication/test/test.pro @@ -17,7 +17,7 @@ symbian: { someTest.sources = test.pro someTest.path = test windowIcon.sources = ../heart.svg - DEPLOYMENT = additional deploy someTest windowIcon + DEPLOYMENT += additional deploy someTest windowIcon LIBS += -lcone -lavkon } -- cgit v0.12 From 44911b0d44f4840e0d7678f8de7227a3a4018d34 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 13 Dec 2010 16:15:51 +0200 Subject: Non-hacky fix for qwidget autotest Turns out there is a nice way for getting current CBA, CEikButtonGroupContainer::Current(), so using that instead of the previous hack. Task-number: QTBUG-15915 Reviewed-by: Janne Koskinen --- tests/auto/qwidget/tst_qwidget.cpp | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 6069383..d611225 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -10029,28 +10029,6 @@ void tst_QWidget::openModal_taskQTBUG_5804() } #ifdef Q_OS_SYMBIAN - -static CEikButtonGroupContainer* cba() -{ - CEikButtonGroupContainer *oldCba = NULL; - - // Due to convoluted/buggy implementation of MEikAppUiFactory interface in Symbian, - // the only way to get the correct cba is to use SwapButtonGroup function. - // Calling SwapButtonGroup doesn't trigger anything, it only changes the value of iToolbar - // member variable, so this double switching should not cause any interference for test. - QT_TRAP_THROWING( - CEikButtonGroupContainer *dummyCba = CEikButtonGroupContainer::NewL( - CEikButtonGroupContainer::ECba, CEikButtonGroupContainer::EHorizontal, NULL, 0); - - oldCba = CEikonEnv::Static()->AppUiFactory()->SwapButtonGroup(dummyCba); - CEikonEnv::Static()->AppUiFactory()->SwapButtonGroup(oldCba); - - delete dummyCba; - ) - - return oldCba; -} - void tst_QWidget::cbaVisibility() { // Test case for task 261048 @@ -10083,7 +10061,7 @@ void tst_QWidget::cbaVisibility() // Verify window decorations i.e. status pane and CBA are visible. CEikStatusPane* statusPane = CEikonEnv::Static()->AppUiFactory()->StatusPane(); QVERIFY(statusPane->IsVisible()); - CEikButtonGroupContainer* buttonGroup = cba(); + CEikButtonGroupContainer* buttonGroup = CEikButtonGroupContainer::Current(); QVERIFY(buttonGroup->IsVisible()); } @@ -10100,7 +10078,7 @@ void tst_QWidget::fullScreenWindowModeTransitions() const QRect fullScreenGeometry = qApp->desktop()->screenGeometry(&widget); const QRect maximumScreenGeometry = qApp->desktop()->availableGeometry(&widget); CEikStatusPane *statusPane = CEikonEnv::Static()->AppUiFactory()->StatusPane(); - CEikButtonGroupContainer *buttonGroup = cba(); + CEikButtonGroupContainer *buttonGroup = CEikButtonGroupContainer::Current(); //Enter widget.showNormal(); @@ -10154,7 +10132,7 @@ void tst_QWidget::maximizedWindowModeTransitions() const QRect fullScreenGeometry = qApp->desktop()->screenGeometry(&widget); const QRect maximumScreenGeometry = qApp->desktop()->availableGeometry(&widget); CEikStatusPane *statusPane = CEikonEnv::Static()->AppUiFactory()->StatusPane(); - CEikButtonGroupContainer *buttonGroup = cba(); + CEikButtonGroupContainer *buttonGroup = CEikButtonGroupContainer::Current(); //Enter widget.showNormal(); @@ -10210,7 +10188,7 @@ void tst_QWidget::minimizedWindowModeTransitions() const QRect fullScreenGeometry = qApp->desktop()->screenGeometry(&widget); const QRect maximumScreenGeometry = qApp->desktop()->availableGeometry(&widget); CEikStatusPane *statusPane = CEikonEnv::Static()->AppUiFactory()->StatusPane(); - CEikButtonGroupContainer *buttonGroup = cba(); + CEikButtonGroupContainer *buttonGroup = CEikButtonGroupContainer::Current(); //Enter widget.showNormal(); @@ -10266,7 +10244,7 @@ void tst_QWidget::normalWindowModeTransitions() const QRect fullScreenGeometry = qApp->desktop()->screenGeometry(&widget); const QRect maximumScreenGeometry = qApp->desktop()->availableGeometry(&widget); CEikStatusPane *statusPane = CEikonEnv::Static()->AppUiFactory()->StatusPane(); - CEikButtonGroupContainer *buttonGroup = cba(); + CEikButtonGroupContainer *buttonGroup = CEikButtonGroupContainer::Current(); //Enter widget.showMaximized(); -- cgit v0.12 From b8f639f27a05043f9f9ac371352508d6527f0123 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 10 Dec 2010 10:00:54 +0100 Subject: Comment a bit more the timer ID allocation code. Also add the notes for where to place .loadAcquire when that function exists. Reviewed-By: Bradley T. Hughes --- src/corelib/kernel/qabstracteventdispatcher.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qabstracteventdispatcher.cpp b/src/corelib/kernel/qabstracteventdispatcher.cpp index bcf4477..1c1c6e3 100644 --- a/src/corelib/kernel/qabstracteventdispatcher.cpp +++ b/src/corelib/kernel/qabstracteventdispatcher.cpp @@ -120,11 +120,20 @@ void QAbstractEventDispatcherPrivate::init() } } +// Timer IDs are implemented using a free-list; +// there's a vector initialized with: +// X[i] = i + 1 +// and nextFreeTimerId starts with 1. +// +// Allocating a timer ID involves taking the ID from +// X[nextFreeTimerId] +// updating nextFreeTimerId to this value and returning the old value +// (continues below). int QAbstractEventDispatcherPrivate::allocateTimerId() { int timerId, newTimerId; do { - timerId = nextFreeTimerId; + timerId = nextFreeTimerId; //.loadAcquire(); // ### FIXME Proper memory ordering semantics // which bucket are we looking in? int which = timerId & 0x00ffffff; @@ -148,6 +157,17 @@ int QAbstractEventDispatcherPrivate::allocateTimerId() return timerId; } +// Releasing a timer ID requires putting the current ID back in the vector; +// we do it by setting: +// X[timerId] = nextFreeTimerId; +// then we update nextFreeTimerId to the timer we've just released +// +// The extra code in allocateTimerId and releaseTimerId are ABA prevention +// and bucket memory. The buckets are simply to make sure we allocate only +// the necessary number of timers. See above. +// +// ABA prevention simply adds a value to 7 of the top 8 bits when resetting +// nextFreeTimerId. void QAbstractEventDispatcherPrivate::releaseTimerId(int timerId) { int which = timerId & 0x00ffffff; @@ -157,7 +177,7 @@ void QAbstractEventDispatcherPrivate::releaseTimerId(int timerId) int freeId, newTimerId; do { - freeId = nextFreeTimerId; + freeId = nextFreeTimerId;//.loadAcquire(); // ### FIXME Proper memory ordering semantics b[at] = freeId & 0x00ffffff; newTimerId = prepareNewValueWithSerialNumber(freeId, timerId); -- cgit v0.12 From f0a892a46fdc438277c8b401c267db4bd92aec1b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 13 Dec 2010 14:50:07 +0100 Subject: Fix ABA problem with: the serial must be updated on all accesses The nextFreeTimerId's serial counter was only being updated on timer ID releasing. It needs to be updated on allocation too. Reviewed-by: Bradley T. Hughes --- src/corelib/kernel/qabstracteventdispatcher.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qabstracteventdispatcher.cpp b/src/corelib/kernel/qabstracteventdispatcher.cpp index 1c1c6e3..5619921 100644 --- a/src/corelib/kernel/qabstracteventdispatcher.cpp +++ b/src/corelib/kernel/qabstracteventdispatcher.cpp @@ -151,7 +151,7 @@ int QAbstractEventDispatcherPrivate::allocateTimerId() } } - newTimerId = b[at]; + newTimerId = prepareNewValueWithSerialNumber(timerId, b[at]); } while (!nextFreeTimerId.testAndSetRelaxed(timerId, newTimerId)); return timerId; -- cgit v0.12 From a02a747a9d5294127dfe3e676a2759e228257e70 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 13 Dec 2010 14:58:16 +0100 Subject: Use constants the timer ID masks instead of values everywhere Reviewed-By: Bradley T. Hughes --- src/corelib/kernel/qabstracteventdispatcher.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/corelib/kernel/qabstracteventdispatcher.cpp b/src/corelib/kernel/qabstracteventdispatcher.cpp index 5619921..002d360 100644 --- a/src/corelib/kernel/qabstracteventdispatcher.cpp +++ b/src/corelib/kernel/qabstracteventdispatcher.cpp @@ -77,10 +77,14 @@ Q_DESTRUCTOR_FUNCTION(timerIdsDestructorFunction) static QBasicAtomicInt nextFreeTimerId = Q_BASIC_ATOMIC_INITIALIZER(1); +static const int TimerIdMask = 0x00ffffff; +static const int TimerSerialMask = ~TimerIdMask & ~0x80000000; +static const int TimerSerialCounter = TimerIdMask + 1; + // avoid the ABA-problem by using 7 of the top 8 bits of the timerId as a serial number static inline int prepareNewValueWithSerialNumber(int oldId, int newId) { - return (newId & 0x00FFFFFF) | ((oldId + 0x01000000) & 0x7f000000); + return (newId & TimerIdMask) | ((oldId + TimerSerialCounter) & TimerSerialMask); } static inline int bucketOffset(int timerId) @@ -136,7 +140,7 @@ int QAbstractEventDispatcherPrivate::allocateTimerId() timerId = nextFreeTimerId; //.loadAcquire(); // ### FIXME Proper memory ordering semantics // which bucket are we looking in? - int which = timerId & 0x00ffffff; + int which = timerId & TimerIdMask; int bucket = bucketOffset(which); int at = bucketIndex(bucket, which); int *b = timerIds[bucket]; @@ -170,7 +174,7 @@ int QAbstractEventDispatcherPrivate::allocateTimerId() // nextFreeTimerId. void QAbstractEventDispatcherPrivate::releaseTimerId(int timerId) { - int which = timerId & 0x00ffffff; + int which = timerId & TimerIdMask; int bucket = bucketOffset(which); int at = bucketIndex(bucket, which); int *b = timerIds[bucket]; @@ -178,7 +182,7 @@ void QAbstractEventDispatcherPrivate::releaseTimerId(int timerId) int freeId, newTimerId; do { freeId = nextFreeTimerId;//.loadAcquire(); // ### FIXME Proper memory ordering semantics - b[at] = freeId & 0x00ffffff; + b[at] = freeId & TimerIdMask; newTimerId = prepareNewValueWithSerialNumber(freeId, timerId); } while (!nextFreeTimerId.testAndSetRelease(freeId, newTimerId)); -- cgit v0.12 From bd9d5c80235ce6d1b005df96c3058b75e82bd6f0 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 13 Dec 2010 15:02:27 +0100 Subject: Add a small protection against releasing a timer twice. The cell corresponding to an allocated timer ID in the free list is unused (because the ID isn't free). So use it to store an invalid value that we can check against the user's value. This provides some protection against a given timer being released twice. Since we store the serial counter of the nextFreeTimerId, getting the same ID twice is a 1-in-128 chance. Reviewed-By: Bradley T. Hughes --- src/corelib/kernel/qabstracteventdispatcher.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qabstracteventdispatcher.cpp b/src/corelib/kernel/qabstracteventdispatcher.cpp index 002d360..bf675a7 100644 --- a/src/corelib/kernel/qabstracteventdispatcher.cpp +++ b/src/corelib/kernel/qabstracteventdispatcher.cpp @@ -132,18 +132,24 @@ void QAbstractEventDispatcherPrivate::init() // Allocating a timer ID involves taking the ID from // X[nextFreeTimerId] // updating nextFreeTimerId to this value and returning the old value +// +// When the timer ID is allocated, its cell in the vector is unused (it's a +// free list). As an added protection, we use the cell to store an invalid +// (negative) value that we can later check for integrity. +// // (continues below). int QAbstractEventDispatcherPrivate::allocateTimerId() { int timerId, newTimerId; + int at, *b; do { timerId = nextFreeTimerId; //.loadAcquire(); // ### FIXME Proper memory ordering semantics // which bucket are we looking in? int which = timerId & TimerIdMask; int bucket = bucketOffset(which); - int at = bucketIndex(bucket, which); - int *b = timerIds[bucket]; + at = bucketIndex(bucket, which); + b = timerIds[bucket]; if (!b) { // allocate a new bucket @@ -158,6 +164,8 @@ int QAbstractEventDispatcherPrivate::allocateTimerId() newTimerId = prepareNewValueWithSerialNumber(timerId, b[at]); } while (!nextFreeTimerId.testAndSetRelaxed(timerId, newTimerId)); + b[at] = -timerId; + return timerId; } @@ -179,6 +187,8 @@ void QAbstractEventDispatcherPrivate::releaseTimerId(int timerId) int at = bucketIndex(bucket, which); int *b = timerIds[bucket]; + Q_ASSERT(b[at] == -timerId); + int freeId, newTimerId; do { freeId = nextFreeTimerId;//.loadAcquire(); // ### FIXME Proper memory ordering semantics -- cgit v0.12 From 8d0863f175199384e41a00fa18a9ea7d177c7f0e Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 13 Dec 2010 22:57:17 +0100 Subject: qrgb565: Use the trivial qt_memconvert() and qt_rectconvert() Use memcpy() instead of the generic conversion routines where both template arguments are qrgb565. Yields a massive performance gain for tiling opaque (background) images in WebKit on 16-bit displays. This was previously restricted to Q_WS_QWS for some unknown reason. Reviewed-by: Benjamin Poulain --- src/gui/painting/qdrawhelper_p.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index 0cc2e40..33fd21e 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -1684,9 +1684,7 @@ QT_TRIVIAL_MEMCONVERT_IMPL(qrgb888) QT_TRIVIAL_MEMCONVERT_IMPL(qargb6666) QT_TRIVIAL_MEMCONVERT_IMPL(qrgb666) QT_TRIVIAL_MEMCONVERT_IMPL(quint16) -#ifdef Q_WS_QWS QT_TRIVIAL_MEMCONVERT_IMPL(qrgb565) -#endif QT_TRIVIAL_MEMCONVERT_IMPL(qargb8565) QT_TRIVIAL_MEMCONVERT_IMPL(qargb8555) QT_TRIVIAL_MEMCONVERT_IMPL(qrgb555) @@ -1783,9 +1781,7 @@ QT_RECTCONVERT_TRIVIAL_IMPL(quint32) QT_RECTCONVERT_TRIVIAL_IMPL(qrgb888) QT_RECTCONVERT_TRIVIAL_IMPL(qargb6666) QT_RECTCONVERT_TRIVIAL_IMPL(qrgb666) -#ifdef Q_WS_QWS QT_RECTCONVERT_TRIVIAL_IMPL(qrgb565) -#endif QT_RECTCONVERT_TRIVIAL_IMPL(qargb8565) QT_RECTCONVERT_TRIVIAL_IMPL(quint16) QT_RECTCONVERT_TRIVIAL_IMPL(qargb8555) -- cgit v0.12 From 2eee49127b80b5b56c605f76ccea004b03d89577 Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Tue, 14 Dec 2010 11:22:50 +1000 Subject: Remove active selection when TextEdit loses focus Task-number: QTBUG-15341 Reviewed-by: Yann Bodson --- .../graphicsitems/qdeclarativetextedit.cpp | 14 ++++++++ .../graphicsitems/qdeclarativetextedit_p.h | 1 + .../tst_qdeclarativetextedit.cpp | 40 ++++++++++++++++++++++ 3 files changed, 55 insertions(+) diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index e05f4e4..1042cf1 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -994,6 +994,20 @@ void QDeclarativeTextEditPrivate::focusChanged(bool hasFocus) QDeclarativeItemPrivate::focusChanged(hasFocus); } +void QDeclarativeTextEdit::focusOutEvent(QFocusEvent *event) +{ + Q_D(QDeclarativeTextEdit); + if (event->reason() != Qt::ActiveWindowFocusReason + && event->reason() != Qt::PopupFocusReason) { + QTextCursor cursor = d->control->textCursor(); + if (cursor.hasSelection()) { + cursor.clearSelection(); + d->control->setTextCursor(cursor); + } + } + QDeclarativePaintedItem::focusOutEvent(event); +} + /*! \qmlmethod void TextEdit::selectAll() diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p.h index 68fde3d..6826cb5 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit_p.h +++ b/src/declarative/graphicsitems/qdeclarativetextedit_p.h @@ -249,6 +249,7 @@ protected: void keyPressEvent(QKeyEvent *); void keyReleaseEvent(QKeyEvent *); void focusInEvent(QFocusEvent *event); + void focusOutEvent(QFocusEvent *event); // mouse filter? void mousePressEvent(QGraphicsSceneMouseEvent *event); diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index a7971cc..ed02451 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -110,6 +110,7 @@ private slots: void mouseSelection_data(); void mouseSelection(); void inputMethodHints(); + void clearSelectionOnFocusLost(); void cursorDelegate(); void delegateLoading_data(); @@ -748,6 +749,45 @@ void tst_qdeclarativetextedit::inputMethodHints() QVERIFY(textEditObject->inputMethodHints() & Qt::ImhUppercaseOnly); } +// QTBUG-15341 +void tst_qdeclarativetextedit::clearSelectionOnFocusLost() +{ + + // create a visible scene with two text edits + QGraphicsScene scene; + QGraphicsView view(&scene); + QDeclarativeTextEdit edit; + QDeclarativeTextEdit secondEdit; + edit.setText("Hello world!"); + scene.addItem(&edit); + scene.addItem(&secondEdit); + view.show(); + QApplication::setActiveWindow(&view); + QTest::qWaitForWindowShown(&view); + QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); + + int index = 0; + while (index < Qt::NoFocusReason) { + + // focus the first text edit and select text + edit.setFocus(true); + edit.selectAll(); + QVERIFY(edit.hasActiveFocus() && !secondEdit.hasActiveFocus()); + QCOMPARE(edit.selectedText().size(), 12); + + // lose focus in the first text edit + qobject_cast(&secondEdit)->setFocus(Qt::FocusReason(index)); + QVERIFY(!edit.hasActiveFocus() && secondEdit.hasActiveFocus()); + + // depending on the focus reason, selection should now be cleared + bool clearSelection = (index != Qt::ActiveWindowFocusReason && index != Qt::PopupFocusReason); + QCOMPARE(edit.selectedText().isEmpty(), clearSelection); + index++; + } +} + + + void tst_qdeclarativetextedit::cursorDelegate() { QDeclarativeView* view = createView(SRCDIR "/data/cursorTest.qml"); -- cgit v0.12 From e4257e41c1c9e764d27f1c61f9173c34444236f3 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Tue, 14 Dec 2010 14:27:38 +1000 Subject: Abort working replies with error when network session fails. Otherwise the connections will stay in a zombie state until the TCP keep alive timer times out in a couple of hours. Task-number: Maemo 201619 --- src/network/access/qnetworkreplyimpl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index cf6e674..3d1df06 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -271,8 +271,8 @@ void QNetworkReplyImplPrivate::_q_networkSessionConnected() void QNetworkReplyImplPrivate::_q_networkSessionFailed() { - // Abort waiting replies. - if (state == WaitingForSession) { + // Abort waiting and working replies. + if (state == WaitingForSession || state == Working) { state = Working; error(QNetworkReplyImpl::UnknownNetworkError, QCoreApplication::translate("QNetworkReply", "Network session error.")); -- cgit v0.12 From f58cf707dd5668ca2849f457e951a9cef7d1d544 Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Tue, 14 Dec 2010 15:27:23 +1000 Subject: Revert a fix made for bug QTBUG-15341 Reverted a commit 2eee49127b80b5b56c605f76ccea004b03d89577 "Remove active selection when TextEdit loses focus". Contrary to TextInput, by default TextEdit keeps the selection visible when the editor loses active focus. If this is not wanted, a property called persistentSelection can be set false to make selection dependant on the focus. --- .../graphicsitems/qdeclarativetextedit.cpp | 14 -------- .../graphicsitems/qdeclarativetextedit_p.h | 1 - .../tst_qdeclarativetextedit.cpp | 40 ---------------------- 3 files changed, 55 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index 1042cf1..e05f4e4 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -994,20 +994,6 @@ void QDeclarativeTextEditPrivate::focusChanged(bool hasFocus) QDeclarativeItemPrivate::focusChanged(hasFocus); } -void QDeclarativeTextEdit::focusOutEvent(QFocusEvent *event) -{ - Q_D(QDeclarativeTextEdit); - if (event->reason() != Qt::ActiveWindowFocusReason - && event->reason() != Qt::PopupFocusReason) { - QTextCursor cursor = d->control->textCursor(); - if (cursor.hasSelection()) { - cursor.clearSelection(); - d->control->setTextCursor(cursor); - } - } - QDeclarativePaintedItem::focusOutEvent(event); -} - /*! \qmlmethod void TextEdit::selectAll() diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p.h index 6826cb5..68fde3d 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit_p.h +++ b/src/declarative/graphicsitems/qdeclarativetextedit_p.h @@ -249,7 +249,6 @@ protected: void keyPressEvent(QKeyEvent *); void keyReleaseEvent(QKeyEvent *); void focusInEvent(QFocusEvent *event); - void focusOutEvent(QFocusEvent *event); // mouse filter? void mousePressEvent(QGraphicsSceneMouseEvent *event); diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index ed02451..a7971cc 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -110,7 +110,6 @@ private slots: void mouseSelection_data(); void mouseSelection(); void inputMethodHints(); - void clearSelectionOnFocusLost(); void cursorDelegate(); void delegateLoading_data(); @@ -749,45 +748,6 @@ void tst_qdeclarativetextedit::inputMethodHints() QVERIFY(textEditObject->inputMethodHints() & Qt::ImhUppercaseOnly); } -// QTBUG-15341 -void tst_qdeclarativetextedit::clearSelectionOnFocusLost() -{ - - // create a visible scene with two text edits - QGraphicsScene scene; - QGraphicsView view(&scene); - QDeclarativeTextEdit edit; - QDeclarativeTextEdit secondEdit; - edit.setText("Hello world!"); - scene.addItem(&edit); - scene.addItem(&secondEdit); - view.show(); - QApplication::setActiveWindow(&view); - QTest::qWaitForWindowShown(&view); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); - - int index = 0; - while (index < Qt::NoFocusReason) { - - // focus the first text edit and select text - edit.setFocus(true); - edit.selectAll(); - QVERIFY(edit.hasActiveFocus() && !secondEdit.hasActiveFocus()); - QCOMPARE(edit.selectedText().size(), 12); - - // lose focus in the first text edit - qobject_cast(&secondEdit)->setFocus(Qt::FocusReason(index)); - QVERIFY(!edit.hasActiveFocus() && secondEdit.hasActiveFocus()); - - // depending on the focus reason, selection should now be cleared - bool clearSelection = (index != Qt::ActiveWindowFocusReason && index != Qt::PopupFocusReason); - QCOMPARE(edit.selectedText().isEmpty(), clearSelection); - index++; - } -} - - - void tst_qdeclarativetextedit::cursorDelegate() { QDeclarativeView* view = createView(SRCDIR "/data/cursorTest.qml"); -- cgit v0.12 From c34225b62ea2dd2a545baf2ade41629be6a55473 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Tue, 14 Dec 2010 13:59:36 +1000 Subject: Clarify that XmlListModel is read only --- src/declarative/util/qdeclarativexmllistmodel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index ce5b483..49a12b1 100644 --- a/src/declarative/util/qdeclarativexmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -503,9 +503,9 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty Date: Tue, 14 Dec 2010 16:38:02 +1000 Subject: Docs: implications of creating network access managers in other threads Task-number: QTBUG-16032 --- .../qdeclarativenetworkaccessmanagerfactory.cpp | 53 ++++++++++++++-------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp b/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp index d22798d..36e9721 100644 --- a/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp +++ b/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp @@ -46,27 +46,44 @@ QT_BEGIN_NAMESPACE /*! \class QDeclarativeNetworkAccessManagerFactory \since 4.7 - \brief The QDeclarativeNetworkAccessManagerFactory class provides a factory for QNetworkAccessManager for use by a Qt Declarative engine. + \brief The QDeclarativeNetworkAccessManagerFactory class creates QNetworkAccessManager instances for a QML engine. - QNetworkAccessManager is used for all network access by QML. - By implementing a factory it is possible to create custom - QNetworkAccessManager with specialized caching, proxy and - cookie support. + A QML engine uses QNetworkAccessManager for all network access. + By implementing a factory, it is possible to provide the QML engine + with custom QNetworkAccessManager instances with specialized caching, + proxy and cookies support. - To implement a factory, subclass QDeclarativeNetworkAccessManagerFactory and implement - the create() method. + To implement a factory, subclass QDeclarativeNetworkAccessManagerFactory and + implement the virtual create() method, then assign it to the relevant QML + engine using QDeclarativeEngine::setNetworkAccessManagerFactory(). - To use a factory, assign it to the relevant QDeclarativeEngine using - QDeclarativeEngine::setNetworkAccessManagerFactory(). + Note the QML engine may create QNetworkAccessManager instances + from multiple threads. Because of this, the implementation of the create() + method must be \l{Reentrancy and Thread-Safety}{reentrant}. In addition, + the developer should be careful if the signals of the object to be + returned from create() are connected to the slots of an object that may + be created in a different thread: - Note: the create() method may be called by multiple threads, so ensure the - implementation of this method is reentrant. + \list + \o The QML engine internally handles all requests, and cleans up any + QNetworkReply objects it creates. Receiving the + QNetworkAccessManager::finished() signal in another thread may not + provide the receiver with a valid reply object if it has already + been deleted. + \o Authentication details provided to QNetworkAccessManager::authenticationRequired() + must be provided immediately, so this signal cannot be connected as a + Qt::QueuedConnection (or as the default Qt::AutoConnection from another + thread). + \endlist + + For more information about signals and threads, see + \l {Threads and QObjects} and \l {Signals and Slots Across Threads}. - \sa QDeclarativeEngine::setNetworkAccessManagerFactory(), {declarative/cppextensions/networkaccessmanagerfactory}{NetworkAccessManagerFactory example} + \sa {declarative/cppextensions/networkaccessmanagerfactory}{NetworkAccessManagerFactory example} */ /*! - The destructor is empty. + Destroys the factory. The default implementation does nothing. */ QDeclarativeNetworkAccessManagerFactory::~QDeclarativeNetworkAccessManagerFactory() { @@ -75,13 +92,9 @@ QDeclarativeNetworkAccessManagerFactory::~QDeclarativeNetworkAccessManagerFactor /*! \fn QNetworkAccessManager *QDeclarativeNetworkAccessManagerFactory::create(QObject *parent) - Implement this method to create a QNetworkAccessManager with \a parent. - This allows proxies, caching and cookie support to be setup appropriately. - - This method must return a new QNetworkAccessManager each time it is called. - The parent of the QNetworkAccessManager must be the \a parent provided. - The QNetworkAccessManager(s) created by this - function will be destroyed automatically when their parent is destroyed. + Creates and returns a network access manager with the specified \a parent. + This method must return a new QNetworkAccessManager instance each time + it is called. Note: this method may be called by multiple threads, so ensure the implementation of this method is reentrant. -- cgit v0.12 From 725716bcf158988ac664da8f8bcd2d9a8e91a916 Mon Sep 17 00:00:00 2001 From: axis Date: Fri, 10 Dec 2010 10:32:11 +0100 Subject: Fixed several compile and deployment issues in the mmf phonon plugin. RevBy: Trust me --- src/3rdparty/phonon/mmf/abstractaudioeffect.h | 2 +- src/3rdparty/phonon/mmf/audioequalizer.cpp | 2 +- src/3rdparty/phonon/mmf/bassboost.cpp | 2 +- src/3rdparty/phonon/mmf/environmentalreverb.cpp | 2 +- src/3rdparty/phonon/mmf/loudness.cpp | 2 +- src/3rdparty/phonon/mmf/stereowidening.cpp | 2 +- src/plugins/phonon/mmf/mmf.pro | 4 ++-- src/s60installs/s60installs.pro | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.h b/src/3rdparty/phonon/mmf/abstractaudioeffect.h index 8879636..70adcf6 100644 --- a/src/3rdparty/phonon/mmf/abstractaudioeffect.h +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.h @@ -21,7 +21,7 @@ along with this library. If not, see . #include -#include +#include #include diff --git a/src/3rdparty/phonon/mmf/audioequalizer.cpp b/src/3rdparty/phonon/mmf/audioequalizer.cpp index 28433f6..1d2bbd4 100644 --- a/src/3rdparty/phonon/mmf/audioequalizer.cpp +++ b/src/3rdparty/phonon/mmf/audioequalizer.cpp @@ -16,7 +16,7 @@ along with this library. If not, see . */ -#include +#include #include "audioequalizer.h" QT_BEGIN_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/bassboost.cpp b/src/3rdparty/phonon/mmf/bassboost.cpp index 81d9208..67076f6 100644 --- a/src/3rdparty/phonon/mmf/bassboost.cpp +++ b/src/3rdparty/phonon/mmf/bassboost.cpp @@ -16,7 +16,7 @@ along with this library. If not, see . */ -#include +#include #include "bassboost.h" QT_BEGIN_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/environmentalreverb.cpp b/src/3rdparty/phonon/mmf/environmentalreverb.cpp index c500385..d4f5223 100644 --- a/src/3rdparty/phonon/mmf/environmentalreverb.cpp +++ b/src/3rdparty/phonon/mmf/environmentalreverb.cpp @@ -16,7 +16,7 @@ along with this library. If not, see . */ -#include +#include #include "environmentalreverb.h" QT_BEGIN_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/loudness.cpp b/src/3rdparty/phonon/mmf/loudness.cpp index 22d7518..ca05ab0 100644 --- a/src/3rdparty/phonon/mmf/loudness.cpp +++ b/src/3rdparty/phonon/mmf/loudness.cpp @@ -16,7 +16,7 @@ along with this library. If not, see . */ -#include +#include #include "loudness.h" QT_BEGIN_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/stereowidening.cpp b/src/3rdparty/phonon/mmf/stereowidening.cpp index e452160..f90651b 100644 --- a/src/3rdparty/phonon/mmf/stereowidening.cpp +++ b/src/3rdparty/phonon/mmf/stereowidening.cpp @@ -16,7 +16,7 @@ along with this library. If not, see . */ -#include +#include #include "stereowidening.h" QT_BEGIN_NAMESPACE diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index 691fc80..5d7b61d 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -103,7 +103,7 @@ symbian { exists($${EPOCROOT}epoc32/include/mw/downloadmgrclient.h) { HEADERS += $$PHONON_MMF_DIR/download.h SOURCES += $$PHONON_MMF_DIR/download.cpp - LIBS += -ldownloadmgr + LIBS += -lDownloadMgr DEFINES += PHONON_MMF_PROGRESSIVE_DOWNLOAD } } @@ -125,7 +125,7 @@ symbian { LIBS += -lmediaclientaudiostream # For CMdaAudioOutputStream # These are for effects. - LIBS += -lAudioEqualizerEffect -lBassBoostEffect -lDistanceAttenuationEffect -lDopplerBase -lEffectBase -lEnvironmentalReverbEffect -lListenerDopplerEffect -lListenerLocationEffect -lListenerOrientationEffect -lLocationBase -lLoudnessEffect -lOrientationBase -lSourceDopplerEffect -lSourceLocationEffect -lSourceOrientationEffect -lStereoWideningEffect + LIBS += -lAudioEqualizerEffect -lBassBoostEffect -lDistanceAttenuationEffect -lDopplerbase -lEffectBase -lEnvironmentalReverbEffect -lListenerDopplerEffect -lListenerLocationEffect -lListenerOrientationEffect -lLocationBase -lLoudnessEffect -lOrientationBase -lSourceDopplerEffect -lSourceLocationEffect -lSourceOrientationEffect -lStereoWideningEffect # This is needed for having the .qtplugin file properly created on Symbian. QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/phonon_backend diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro index ff67bcf..5a435cd 100644 --- a/src/s60installs/s60installs.pro +++ b/src/s60installs/s60installs.pro @@ -132,7 +132,7 @@ symbian: { codecs_plugins.path = c:$$QT_PLUGINS_BASE_DIR/codecs contains(QT_CONFIG, phonon-backend) { - phonon_backend_plugins.sources += $$QMAKE_LIBDIR_QT/phonon_mmf$${QT_LIBINFIX}.dll + phonon_backend_plugins.sources += $$QT_BUILD_TREE/plugins/phonon_backend/phonon_mmf$${QT_LIBINFIX}.dll phonon_backend_plugins.path = c:$$QT_PLUGINS_BASE_DIR/phonon_backend DEPLOYMENT += phonon_backend_plugins -- cgit v0.12 From 6aa1ab84404c92f2048270b1932fa10cecdcc58d Mon Sep 17 00:00:00 2001 From: axis Date: Fri, 10 Dec 2010 15:35:06 +0100 Subject: Fixed a bug in the input methods on S60 with QGraphicsWebView. The bug happened because we did not expect to receive a call to CancelFepInlineEdit() when the widget had not previously been given any preedit text by S60. However, this can happen, and if it happens at the same time that there is a temporarily visible character in the widget (because it will be obscured as a password a second later), then the temporary character would be discarded. Fixed by checking in the beginning of CancelFepInlineEdit() whether we currently have any temporary preedit text or not, and if we do, we don't clear the contents, since it is the input context itself that generated the preedit text, not S60. Also made sure that the temporary preedit text is committed if we receive a call to UpdateFepInlineTextL(), which may sometimes happen without a call to StartFepInlineEditL(). Task: QT-4314 AutoTest: Included RevBy: Shane Kearns --- src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 8 ++ tests/auto/qinputcontext/qinputcontext.pro | 2 + tests/auto/qinputcontext/tst_qinputcontext.cpp | 141 +++++++++++++++++++++++- 3 files changed, 148 insertions(+), 3 deletions(-) diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index 4a1b9b9..686f388 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -657,6 +657,8 @@ void QCoeFepInputContext::UpdateFepInlineTextL(const TDesC& aNewInlineText, if (!w) return; + commitTemporaryPreeditString(); + m_inlinePosition = aPositionOfInsertionPointInInlineText; QList attributes; @@ -694,6 +696,12 @@ void QCoeFepInputContext::SetInlineEditingCursorVisibilityL(TBool aCursorVisibil void QCoeFepInputContext::CancelFepInlineEdit() { + // We are not supposed to ever have a tempPreeditString and a real preedit string + // from S60 at the same time, so it should be safe to rely on this test to determine + // whether we should honor S60's request to clear the text or not. + if (m_hasTempPreeditString) + return; + QList attributes; QInputMethodEvent event(QLatin1String(""), attributes); event.setCommitString(QLatin1String(""), 0, 0); diff --git a/tests/auto/qinputcontext/qinputcontext.pro b/tests/auto/qinputcontext/qinputcontext.pro index ec6831e..4b3ab96 100644 --- a/tests/auto/qinputcontext/qinputcontext.pro +++ b/tests/auto/qinputcontext/qinputcontext.pro @@ -1,6 +1,8 @@ load(qttest_p4) SOURCES += tst_qinputcontext.cpp +contains(QT_CONFIG, webkit):QT += webkit + symbian { LIBS += -lws32 -lcone } diff --git a/tests/auto/qinputcontext/tst_qinputcontext.cpp b/tests/auto/qinputcontext/tst_qinputcontext.cpp index 5a258a9..020f177 100644 --- a/tests/auto/qinputcontext/tst_qinputcontext.cpp +++ b/tests/auto/qinputcontext/tst_qinputcontext.cpp @@ -50,6 +50,13 @@ #include #include #include +#include +#include + +#ifdef QT_WEBKIT_LIB +#include +#include +#endif #ifdef Q_OS_SYMBIAN #include @@ -466,6 +473,115 @@ void tst_QInputContext::focusProxy() QCOMPARE(gic->focusWidget(), &proxy); } +#ifdef QT_WEBKIT_LIB +class AutoWebView : public QWebView +{ + Q_OBJECT + +public: + AutoWebView() + : m_length(0) + , m_mode(QLineEdit::Normal) + { + updatePage(); + } + ~AutoWebView() {} + + void updatePage() + { + // The update might reset the input method parameters. + bool imEnabled = testAttribute(Qt::WA_InputMethodEnabled); + Qt::InputMethodHints hints = inputMethodHints(); + + QString page = "" + "
"; + if (m_mode == QLineEdit::Password) + page = page.arg("password"); + else + page = page.arg("text"); + + if (m_length == 0) + page = page.arg(""); + else + page = page.arg("maxlength=\"" + QString::number(m_length) + "\""); + + setHtml(page); + + setAttribute(Qt::WA_InputMethodEnabled, imEnabled); + setInputMethodHints(hints); + } + void setMaxLength(int length) + { + m_length = length; + updatePage(); + } + void setEchoMode(QLineEdit::EchoMode mode) + { + m_mode = mode; + updatePage(); + } + + int m_length; + QLineEdit::EchoMode m_mode; +}; + +class AutoGraphicsWebView : public QGraphicsView +{ + Q_OBJECT + +public: + AutoGraphicsWebView() + : m_length(0) + , m_mode(QLineEdit::Normal) + { + m_scene.addItem(&m_view); + setScene(&m_scene); + m_view.setFocus(); + updatePage(); + } + ~AutoGraphicsWebView() {} + + void updatePage() + { + // The update might reset the input method parameters. + bool imEnabled = testAttribute(Qt::WA_InputMethodEnabled); + Qt::InputMethodHints hints = inputMethodHints(); + + QString page = "" + "
"; + if (m_mode == QLineEdit::Password) + page = page.arg("password"); + else + page = page.arg("text"); + + if (m_length == 0) + page = page.arg(""); + else + page = page.arg("maxlength=\"" + QString::number(m_length) + "\""); + + m_view.setHtml(page); + + setAttribute(Qt::WA_InputMethodEnabled, imEnabled); + setInputMethodHints(hints); + } + void setMaxLength(int length) + { + m_length = length; + updatePage(); + } + void setEchoMode(QLineEdit::EchoMode mode) + { + m_mode = mode; + updatePage(); + } + + int m_length; + QLineEdit::EchoMode m_mode; + QGraphicsScene m_scene; + QGraphicsWebView m_view; +}; +#endif // QT_WEBKIT_LIB + void tst_QInputContext::symbianTestCoeFepInputContext_data() { #ifdef Q_OS_SYMBIAN @@ -481,6 +597,10 @@ void tst_QInputContext::symbianTestCoeFepInputContext_data() symbianTestCoeFepInputContext_addData(); symbianTestCoeFepInputContext_addData(); symbianTestCoeFepInputContext_addData(); +# ifdef QT_WEBKIT_LIB + symbianTestCoeFepInputContext_addData(); + symbianTestCoeFepInputContext_addData(); +# endif #endif } @@ -1087,13 +1207,28 @@ void tst_QInputContext::symbianTestCoeFepInputContext() editwidget->setAttribute(Qt::WA_InputMethodEnabled, inputMethodEnabled); editwidget->setInputMethodHints(inputMethodHints); - QLineEdit *lineedit = qobject_cast(editwidget); - if (lineedit) { + if (QLineEdit *lineedit = qobject_cast(editwidget)) { if (maxLength > 0) lineedit->setMaxLength(maxLength); lineedit->setEchoMode(echoMode); +#ifdef QT_WEBKIT_LIB + } else if (AutoWebView *webView = qobject_cast(editwidget)) { + if (maxLength > 0) + webView->setMaxLength(maxLength); + webView->setEchoMode(echoMode); + // WebKit disables T9 everywhere. + if (inputMethodEnabled && !(inputMethodHints & Qt::ImhNoPredictiveText)) + return; + } else if (AutoGraphicsWebView *webView = qobject_cast(editwidget)) { + if (maxLength > 0) + webView->setMaxLength(maxLength); + webView->setEchoMode(echoMode); + // WebKit disables T9 everywhere. + if (inputMethodEnabled && !(inputMethodHints & Qt::ImhNoPredictiveText)) + return; +#endif } else if (maxLength > 0 || echoMode != QLineEdit::Normal) { - // Only QLineEdits support these features so don't attempt any tests using those + // Only some widgets support these features so don't attempt any tests using those // on other widgets. return; } -- cgit v0.12 From 284211ccbd2cbdfea46cdf4b8628a1a967271985 Mon Sep 17 00:00:00 2001 From: Michael Dominic K Date: Tue, 14 Dec 2010 10:26:39 +0100 Subject: Prevent ::flush from being called on QGLWindowSurface if no painting happened. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge-request: 2527 Reviewed-by: Harald Fernengel Reviewed-by: Samuel Rødal --- src/opengl/qwindowsurface_gl.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index f64b93c..6749826 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -267,6 +267,7 @@ struct QGLWindowSurfacePrivate int tried_pb : 1; int destructive_swap_buffers : 1; int geometry_updated : 1; + int did_paint : 1; QGLContext *ctx; @@ -330,6 +331,7 @@ QGLWindowSurface::QGLWindowSurface(QWidget *window) d_ptr->glDevice.d = d_ptr; d_ptr->q_ptr = this; d_ptr->geometry_updated = false; + d_ptr->did_paint = false; } QGLWindowSurface::~QGLWindowSurface() @@ -461,6 +463,8 @@ void QGLWindowSurface::beginPaint(const QRegion &) glClearColor(0.0, 0.0, 0.0, 0.0); glClear(clearFlags); } + + d_ptr->did_paint = true; } void QGLWindowSurface::endPaint(const QRegion &rgn) @@ -513,6 +517,13 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint & if (d_ptr->geometry_updated) return; + // did_paint is set to true in ::beginPaint. ::beginPaint means that we + // at least cleared the background (= painted something). In EGL API it's a + // mistakte to call swapBuffers if nothing was painted. This check protects + // the flush func from being executed if it's for nothing. + if (! d_ptr->did_paint) + return; + QWidget *parent = widget->internalWinId() ? widget : widget->nativeParentWidget(); Q_ASSERT(parent); @@ -736,6 +747,8 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint & ctx->swapBuffers(); else glFlush(); + + d_ptr->did_paint = false; } -- cgit v0.12 From 4d93a606ea0438be8062fda82baf639a9ced78ba Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Tue, 14 Dec 2010 10:28:26 +0100 Subject: Trivial: Fix coding style Fix coding style of merge request --- src/opengl/qwindowsurface_gl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index 6749826..7dc7dc7 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -521,7 +521,7 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint & // at least cleared the background (= painted something). In EGL API it's a // mistakte to call swapBuffers if nothing was painted. This check protects // the flush func from being executed if it's for nothing. - if (! d_ptr->did_paint) + if (!d_ptr->did_paint) return; QWidget *parent = widget->internalWinId() ? widget : widget->nativeParentWidget(); -- cgit v0.12 From e864a530a5c48459c433518ff6ad893f33ec93d8 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 14 Dec 2010 10:57:11 +0100 Subject: Fix failing tst_QGraphicsView::QTBUG_16063_microFocusRect auto-test This ammends commit 0af1f5508e165f3b494ab236cb1cdf1b0edcffa5. Reviewed-by: trust me --- tests/auto/qgraphicsview/tst_qgraphicsview.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index e1fbaee..e259177 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -4455,7 +4455,7 @@ class IMItem : public QGraphicsRectItem { public: IMItem(QGraphicsItem *parent = 0): - QGraphicsRectItem(mf.adjusted(-5, -5, 5, 5), parent) + QGraphicsRectItem(QRectF(0, 0, 20, 20), parent) { setFlag(QGraphicsItem::ItemIsFocusable, true); setFlag(QGraphicsItem::ItemAcceptsInputMethod, true); @@ -4486,7 +4486,7 @@ void tst_QGraphicsView::QTBUG_16063_microFocusRect() scene.setFocusItem(item); view.setFocus(); QRectF mfv = view.inputMethodQuery(Qt::ImMicroFocus).toRectF(); - QCOMPARE(mfv, QRectF(13.5, 13.6, 10, 10)); + QCOMPARE(mfv, IMItem::mf.translated(-view.mapToScene(view.sceneRect().toRect()).boundingRect().topLeft())); } QTEST_MAIN(tst_QGraphicsView) -- cgit v0.12 From 736b8205158dd7b98af862a029b273dff6fb716d Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 8 Dec 2010 13:23:23 +0100 Subject: QApplication: fix crash exit whith native windows Regression introduced in 8dd8db250d92521fda619bdcf3e1c859b37b2da0 Patch comes from the task Task-number: QTBUG-15774 --- src/gui/kernel/qapplication.cpp | 6 +++--- tests/auto/qapplication/modal/main.cpp | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index a4ae46b..b4ff7c4 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -1101,6 +1101,9 @@ QApplication::~QApplication() QApplicationPrivate::is_app_closing = true; QApplicationPrivate::is_app_running = false; + delete QWidgetPrivate::mapper; + QWidgetPrivate::mapper = 0; + // delete all widgets if (QWidgetPrivate::allWidgets) { QWidgetSet *mySet = QWidgetPrivate::allWidgets; @@ -1130,9 +1133,6 @@ QApplication::~QApplication() delete d->ignore_cursor; d->ignore_cursor = 0; #endif - delete QWidgetPrivate::mapper; - QWidgetPrivate::mapper = 0; - delete QApplicationPrivate::app_pal; QApplicationPrivate::app_pal = 0; delete QApplicationPrivate::sys_pal; diff --git a/tests/auto/qapplication/modal/main.cpp b/tests/auto/qapplication/modal/main.cpp index f9d8fb4..3eaaa0d 100644 --- a/tests/auto/qapplication/modal/main.cpp +++ b/tests/auto/qapplication/modal/main.cpp @@ -47,6 +47,7 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); + QApplication::setAttribute(Qt::AA_NativeWindows); //QTBUG-15774 base *b = new base(); return app.exec(); } -- cgit v0.12 From 3778c3f5208f3db99d6b23a2a3c4abf1fe2ec64f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Tue, 14 Dec 2010 11:46:57 +0100 Subject: Make sure that d->init() is called from both ctors. QGraphicsLayout uses the protected ctor that did not call d->init(), so all its subclasses was potentially suffering from this. Task-number: QTBUG-15333 Reviewed-by: John Tapsell --- src/gui/graphicsview/qgraphicslayoutitem.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicslayoutitem.cpp b/src/gui/graphicsview/qgraphicslayoutitem.cpp index df13039..b11dc9e 100644 --- a/src/gui/graphicsview/qgraphicslayoutitem.cpp +++ b/src/gui/graphicsview/qgraphicslayoutitem.cpp @@ -129,7 +129,6 @@ void QGraphicsLayoutItemPrivate::init() { sizeHintCacheDirty = true; sizeHintWithConstraintCacheDirty = true; - sizePolicy = QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); } /*! @@ -400,6 +399,7 @@ QGraphicsLayoutItem::QGraphicsLayoutItem(QGraphicsLayoutItem *parent, bool isLay { Q_D(QGraphicsLayoutItem); d->init(); + sizePolicy = QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); d->q_ptr = this; } @@ -410,6 +410,7 @@ QGraphicsLayoutItem::QGraphicsLayoutItem(QGraphicsLayoutItemPrivate &dd) : d_ptr(&dd) { Q_D(QGraphicsLayoutItem); + d->init(); d->q_ptr = this; } -- cgit v0.12 From 542fe69cdeff81acb8f986ff4606043613345dc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Tue, 14 Dec 2010 13:03:43 +0100 Subject: Fix to commit 3778c3f5208f3db99d6b23a2a3c4abf1fe2ec64f This is what could happen if you go to lunch before comitting. --- src/gui/graphicsview/qgraphicslayoutitem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicslayoutitem.cpp b/src/gui/graphicsview/qgraphicslayoutitem.cpp index b11dc9e..0a24aae 100644 --- a/src/gui/graphicsview/qgraphicslayoutitem.cpp +++ b/src/gui/graphicsview/qgraphicslayoutitem.cpp @@ -399,7 +399,7 @@ QGraphicsLayoutItem::QGraphicsLayoutItem(QGraphicsLayoutItem *parent, bool isLay { Q_D(QGraphicsLayoutItem); d->init(); - sizePolicy = QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + d->sizePolicy = QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); d->q_ptr = this; } -- cgit v0.12 From 0727539b89898544047d32e63633790fa0c44b5a Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 14 Dec 2010 14:03:08 +0100 Subject: Don't delete FBO when resetting glyph cache When the glyph cache is cleared because the max texture size has been exceeded, we shouldn't delete the fbo as this is only created in setContext() and will thus not be recreated. All subsequent resizing of the cache will fail. Task-number: QT-3971 Reviewed-by: Samuel --- src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp index 66445cd..1b879c3 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp @@ -83,13 +83,9 @@ void QGLTextureGlyphCache::clear() if (ctx) { QGLShareContextScope scope(ctx); - if (!ctx->d_ptr->workaround_brokenFBOReadBack) - glDeleteFramebuffers(1, &m_fbo); - if (m_width || m_height) glDeleteTextures(1, &m_texture); - m_fbo = 0; m_texture = 0; m_width = 0; m_height = 0; @@ -105,6 +101,13 @@ void QGLTextureGlyphCache::clear() QGLTextureGlyphCache::~QGLTextureGlyphCache() { + if (ctx) { + QGLShareContextScope scope(ctx); + + if (!ctx->d_ptr->workaround_brokenFBOReadBack) + glDeleteFramebuffers(1, &m_fbo); + } + clear(); } -- cgit v0.12 From c031e5808ee406277a5401c69801e5c6e2ebfaea Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Wed, 15 Dec 2010 14:16:36 +1000 Subject: Fix invalid configurations being added to bearermonitor list. --- examples/network/bearermonitor/bearermonitor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/network/bearermonitor/bearermonitor.cpp b/examples/network/bearermonitor/bearermonitor.cpp index 75ffb01..bfa3d1f 100644 --- a/examples/network/bearermonitor/bearermonitor.cpp +++ b/examples/network/bearermonitor/bearermonitor.cpp @@ -226,7 +226,7 @@ void BearerMonitor::updateConfigurations() if (defaultConfiguration.type() == QNetworkConfiguration::ServiceNetwork) updateSnapConfiguration(defaultItem, defaultConfiguration); - } else { + } else if (defaultConfiguration.isValid()) { configurationAdded(defaultConfiguration); } -- cgit v0.12 From c9faf2defa9fa3209e44e8a5c1ae2da8e630d379 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Wed, 8 Dec 2010 17:48:14 +1000 Subject: Ensure that DBus is connected before all uses. In early system startup applications may try to use ICD before it is contactable. Ensure that the connection to ICD is established before all calls are made. If ICD is still not contactable QDBusServiceWatcher is used to monitor registration of the com.nokia.icd2 address and reconnection is attempted once ICD is started. Task-number: Maemo 199755 --- src/plugins/bearer/icd/qicdengine.cpp | 93 ++++++++++++++++++++++++++++++----- src/plugins/bearer/icd/qicdengine.h | 6 +++ 2 files changed, 88 insertions(+), 11 deletions(-) diff --git a/src/plugins/bearer/icd/qicdengine.cpp b/src/plugins/bearer/icd/qicdengine.cpp index bdf4e2e..a5a183b 100644 --- a/src/plugins/bearer/icd/qicdengine.cpp +++ b/src/plugins/bearer/icd/qicdengine.cpp @@ -229,7 +229,7 @@ void IapMonitor::iapRemoved(const QString &iap_id) /******************************************************************************/ QIcdEngine::QIcdEngine(QObject *parent) -: QBearerEngine(parent), iapMonitor(0), m_dbusInterface(0), +: QBearerEngine(parent), iapMonitor(0), m_dbusInterface(0), m_icdServiceWatcher(0), firstUpdate(true), m_scanGoingOn(false) { } @@ -248,9 +248,10 @@ QNetworkConfigurationManager::Capabilities QIcdEngine::capabilities() const QNetworkConfigurationManager::NetworkSessionRequired; } -void QIcdEngine::initialize() +bool QIcdEngine::ensureDBusConnection() { - QMutexLocker locker(&mutex); + if (m_dbusInterface) + return true; // Setup DBus Interface for ICD m_dbusInterface = new QDBusInterface(ICD_DBUS_API_INTERFACE, @@ -259,9 +260,22 @@ void QIcdEngine::initialize() QDBusConnection::systemBus(), this); - // abort if cannot connect to DBus. - if (!m_dbusInterface->isValid()) - return; + if (!m_dbusInterface->isValid()) { + delete m_dbusInterface; + m_dbusInterface = 0; + + if (!m_icdServiceWatcher) { + m_icdServiceWatcher = new QDBusServiceWatcher(ICD_DBUS_API_INTERFACE, + QDBusConnection::systemBus(), + QDBusServiceWatcher::WatchForOwnerChange, + this); + + connect(m_icdServiceWatcher, SIGNAL(serviceOwnerChanged(QString,QString,QString)), + this, SLOT(icdServiceOwnerChanged(QString,QString,QString))); + } + + return false; + } connect(&m_scanTimer, SIGNAL(timeout()), this, SLOT(finishAsyncConfigurationUpdate())); m_scanTimer.setSingleShot(true); @@ -289,6 +303,19 @@ void QIcdEngine::initialize() doRequestUpdate(); getIcdInitialState(); + + return true; +} + +void QIcdEngine::initialize() +{ + QMutexLocker locker(&mutex); + + if (!ensureDBusConnection()) { + locker.unlock(); + emit updateCompleted(); + locker.relock(); + } } static inline QString network_attrs_to_security(uint network_attrs) @@ -792,6 +819,9 @@ QNetworkConfigurationPrivatePointer QIcdEngine::defaultConfiguration() { QMutexLocker locker(&mutex); + if (!ensureDBusConnection()) + return QNetworkConfigurationPrivatePointer(); + // Here we just return [ANY] request to icd and let the icd decide which IAP to connect. return userChoiceConfigurations.value(OSSO_IAP_ANY); } @@ -933,13 +963,52 @@ void QIcdEngine::connectionStateSignalsSlot(QDBusMessage msg) locker.relock(); } +void QIcdEngine::icdServiceOwnerChanged(const QString &serviceName, const QString &oldOwner, + const QString &newOwner) +{ + QMutexLocker locker(&mutex); + + if (newOwner.isEmpty()) { + // Disconnected from ICD, remove all configurations + cleanup(); + delete iapMonitor; + iapMonitor = 0; + delete m_dbusInterface; + m_dbusInterface = 0; + + QMutableHashIterator i(accessPointConfigurations); + while (i.hasNext()) { + i.next(); + + QNetworkConfigurationPrivatePointer ptr = i.value(); + i.remove(); + + locker.unlock(); + emit configurationRemoved(ptr); + locker.relock(); + } + + userChoiceConfigurations.clear(); + } else { + // Connected to ICD ensure connection. + ensureDBusConnection(); + } +} + void QIcdEngine::requestUpdate() { QMutexLocker locker(&mutex); - if (m_scanGoingOn) { + if (!ensureDBusConnection()) { + locker.unlock(); + emit updateCompleted(); + locker.relock(); return; } + + if (m_scanGoingOn) + return; + m_scanGoingOn = true; m_dbusInterface->connection().connect(ICD_DBUS_API_INTERFACE, @@ -956,14 +1025,16 @@ void QIcdEngine::requestUpdate() void QIcdEngine::cancelAsyncConfigurationUpdate() { - if (!m_scanGoingOn) { + if (!ensureDBusConnection()) return; - } + + if (!m_scanGoingOn) + return; + m_scanGoingOn = false; - if (m_scanTimer.isActive()) { + if (m_scanTimer.isActive()) m_scanTimer.stop(); - } m_dbusInterface->connection().disconnect(ICD_DBUS_API_INTERFACE, ICD_DBUS_API_PATH, diff --git a/src/plugins/bearer/icd/qicdengine.h b/src/plugins/bearer/icd/qicdengine.h index d528f15..d5b4fb3 100644 --- a/src/plugins/bearer/icd/qicdengine.h +++ b/src/plugins/bearer/icd/qicdengine.h @@ -53,6 +53,7 @@ QT_BEGIN_NAMESPACE class QNetworkConfigurationPrivate; class IapMonitor; class QDBusInterface; +class QDBusServiceWatcher; inline QNetworkConfiguration::BearerType bearerTypeFromIapType(const QString &iapType) { @@ -147,12 +148,15 @@ private Q_SLOTS: void finishAsyncConfigurationUpdate(); void asyncUpdateConfigurationsSlot(QDBusMessage msg); void connectionStateSignalsSlot(QDBusMessage msg); + void icdServiceOwnerChanged(const QString &serviceName, const QString &oldOwner, + const QString &newOwner); private: void startListeningStateSignalsForAllConnections(); void doRequestUpdate(QList scanned = QList()); void cancelAsyncConfigurationUpdate(); void getIcdInitialState(); + bool ensureDBusConnection(); private: IapMonitor *iapMonitor; @@ -162,6 +166,8 @@ private: QStringList m_typesToBeScanned; QList m_scanResult; + QDBusServiceWatcher *m_icdServiceWatcher; + bool firstUpdate; bool m_scanGoingOn; }; -- cgit v0.12 From e75980a322ea1088e1c6bf60259b8ba853d32444 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Wed, 15 Dec 2010 15:30:43 +1000 Subject: Fix possible null pointer dereference. When parsing a new connection an access point with the same SSID may not have been previously seen. Task-number: QTBUG-15276 --- src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp index 554f9b7..f93b605 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp @@ -743,9 +743,11 @@ QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QStri QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(accessPointId); - mutex.unlock(); - emit configurationRemoved(ptr); - mutex.lock(); + if (ptr) { + mutex.unlock(); + emit configurationRemoved(ptr); + mutex.lock(); + } } break; } -- cgit v0.12 From 27de60f2f6047cb3f698825af96e569fde04ef06 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Wed, 15 Dec 2010 17:06:25 +1000 Subject: Add extra type of embedded license. Marketing needs this for commercial customers. Reviewed-by: Trust Me --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 7141880..aa8d047 100755 --- a/configure +++ b/configure @@ -480,7 +480,7 @@ elif [ $COMMERCIAL_USER = "yes" ]; then # Qt All-OS LICENSE_EXTENSION="-ALLOS" ;; - 8M,* | KM,* | S9,* | SC,* | SU,* | SW,* | X9,* | XC,* | XU,* | XW,*) + 8M,* | KM,* | S9,* | SC,* | SM,* | SU,* | SW,* | X9,* | XC,* | XU,* | XW,*) # Qt for Embedded Linux LICENSE_EXTENSION="-EMBEDDED" ;; -- cgit v0.12 From 915a31420c4f8d04c82103e3dd4d33b468a9334d Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Wed, 15 Dec 2010 11:44:19 +0200 Subject: Resize event for QDesktopWidget was sent too early Some recent changes had caused a change in events sent from avkon to QSymbianControl, causing QDesktopWidget to be get resize event before the client area of application was correct. Moved the resize event sending from HandleStatusPaneSizeChange to HandleResourceChange (case KEikDynamicLayoutVariantSwitch). Task-number: QTBUG-16095 Reviewed-by: Sami Merila --- src/gui/kernel/qapplication_s60.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 81fa4e6..6db1fa8 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -667,9 +667,6 @@ void QSymbianControl::HandleStatusPaneSizeChange() { QS60MainAppUi *s60AppUi = static_cast(S60->appUi()); s60AppUi->HandleStatusPaneSizeChange(); - // Send resize event to trigger desktopwidget workAreaResized signal - QResizeEvent e(qt_desktopWidget->size(), qt_desktopWidget->size()); - QApplication::sendEvent(qt_desktopWidget, &e); } #endif @@ -1310,6 +1307,9 @@ void QSymbianControl::HandleResourceChange(int resourceType) case KEikDynamicLayoutVariantSwitch: { handleClientAreaChange(); + // Send resize event to trigger desktopwidget workAreaResized signal + QResizeEvent e(qt_desktopWidget->size(), qt_desktopWidget->size()); + QApplication::sendEvent(qt_desktopWidget, &e); break; } #endif -- cgit v0.12 From e0aa9897bc2d04054cc65dbe3452bee2ed2eacd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 15 Dec 2010 12:41:08 +0100 Subject: Prevent crash in drawhelper code when the cpu has MMXEXT but no SSE. We can't use the qdrawhelper_sse.cpp or qdrawhelper_sse3dnow.cpp when SSE is not run-time detected, as those are compiled with -msse and MMXEXT is just a subset of SSE. The compiler might choose to use an instruction not in the subset, causing a crash at run-time. Task-number: QTBUG-15693 Reviewed-by: Thiago Macieira --- src/gui/painting/qdrawhelper.cpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 024a69d..62af212 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -7711,17 +7711,6 @@ void qInitDrawhelperAsm() } #endif #endif // SSE -#if defined(QT_HAVE_MMXEXT) && defined(QT_HAVE_SSE) - } else if (features & MMXEXT) { - qt_memfill32 = qt_memfill32_sse; - qDrawHelper[QImage::Format_RGB16].bitmapBlit = qt_bitmapblit16_sse; -# ifdef QT_HAVE_3DNOW - if (features & MMX3DNOW) { - qt_memfill32 = qt_memfill32_sse3dnow; - qDrawHelper[QImage::Format_RGB16].bitmapBlit = qt_bitmapblit16_sse3dnow; - } -# endif // 3DNOW -#endif // MMXEXT } #ifdef QT_HAVE_MMX if (features & MMX) { -- cgit v0.12 From 21b1b5a9af95af10b281176564f14cafa2339006 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Sat, 11 Dec 2010 00:03:14 +0100 Subject: Improve performance of clipping to a scaled QRectF Clipping to a scaled QRectF was so far hitting the slow code path in the raster paintengine that generates clip spans for every line. This is not needed as we also clip translated QRectF's to integer rects. This patch does the same for scaled rectangles and ensures the clipping really happens at the closest pixel boundary. Reviewed-by: Samuel --- src/gui/painting/qpaintengine_raster.cpp | 33 ++++++++++++++++++++++---------- src/gui/painting/qpaintengine_raster_p.h | 2 ++ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 89202ac..4d06c9f 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -1212,7 +1212,7 @@ void QRasterPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) // There are some cases that are not supported by clip(QRect) if (op != Qt::UniteClip && (op != Qt::IntersectClip || !s->clip || s->clip->hasRectClip || s->clip->hasRegionClip)) { - if (s->matrix.type() <= QTransform::TxTranslate + if (s->matrix.type() <= QTransform::TxScale && ((path.shape() == QVectorPath::RectangleHint) || (isRect(points, path.elementCount()) && (!types || (types[0] == QPainterPath::MoveToElement @@ -1224,8 +1224,8 @@ void QRasterPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) #endif QRectF r(points[0], points[1], points[4]-points[0], points[5]-points[1]); - clip(r.toRect(), op); - return; + if (setClipRectInDeviceCoords(s->matrix.mapRect(r).toRect(), op)) + return; } } @@ -1286,7 +1286,6 @@ void QRasterPaintEngine::clip(const QRect &rect, Qt::ClipOperation op) qDebug() << "QRasterPaintEngine::clip(): " << rect << op; #endif - Q_D(QRasterPaintEngine); QRasterPaintEngineState *s = state(); if (op == Qt::NoClip) { @@ -1296,11 +1295,23 @@ void QRasterPaintEngine::clip(const QRect &rect, Qt::ClipOperation op) QPaintEngineEx::clip(rect, op); return; - } else if (op == Qt::ReplaceClip || s->clip == 0) { + } else if (!setClipRectInDeviceCoords(s->matrix.mapRect(rect), op)) { + QPaintEngineEx::clip(rect, op); + return; + } +} + + +bool QRasterPaintEngine::setClipRectInDeviceCoords(const QRect &r, Qt::ClipOperation op) +{ + Q_D(QRasterPaintEngine); + QRect clipRect = r & d->deviceRect; + QRasterPaintEngineState *s = state(); + + if (op == Qt::ReplaceClip || s->clip == 0) { // No current clip, hence we intersect with sysclip and be // done with it... - QRect clipRect = s->matrix.mapRect(rect) & d->deviceRect; QRegion clipRegion = systemClip(); QClipData *clip = new QClipData(d->rasterBuffer->height()); @@ -1316,12 +1327,11 @@ void QRasterPaintEngine::clip(const QRect &rect, Qt::ClipOperation op) s->clip->enabled = true; s->flags.has_clip_ownership = true; - } else { // intersect clip with current clip + } else if (op == Qt::IntersectClip){ // intersect clip with current clip QClipData *base = s->clip; Q_ASSERT(base); if (base->hasRectClip || base->hasRegionClip) { - QRect clipRect = s->matrix.mapRect(rect) & d->deviceRect; if (!s->flags.has_clip_ownership) { s->clip = new QClipData(d->rasterBuffer->height()); s->flags.has_clip_ownership = true; @@ -1332,11 +1342,14 @@ void QRasterPaintEngine::clip(const QRect &rect, Qt::ClipOperation op) s->clip->setClipRegion(base->clipRegion & clipRect); s->clip->enabled = true; } else { - QPaintEngineEx::clip(rect, op); - return; + return false; } + } else { + return false; } + qrasterpaintengine_dirty_clip(d, s); + return true; } diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h index 1016f8d..7d4d3b6 100644 --- a/src/gui/painting/qpaintengine_raster_p.h +++ b/src/gui/painting/qpaintengine_raster_p.h @@ -266,6 +266,8 @@ private: void drawGlyphsS60(const QPointF &p, const QTextItemInt &ti); #endif // Q_OS_SYMBIAN && QT_NO_FREETYPE + bool setClipRectInDeviceCoords(const QRect &r, Qt::ClipOperation op); + inline void ensureBrush(const QBrush &brush) { if (!qbrush_fast_equals(state()->lastBrush, brush) || (brush.style() != Qt::NoBrush && state()->fillFlags)) updateBrush(brush); -- cgit v0.12 From 3e7adcb80a86748608d5517413301cd2b1b8df78 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 15 Dec 2010 16:42:05 +0100 Subject: Check for null-pointer to avoid a crash in textedit demo. Task-number: QTBUG-16125 Reviewed-by: trustme --- demos/textedit/textedit.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/demos/textedit/textedit.cpp b/demos/textedit/textedit.cpp index 165c97c..9fa1949 100644 --- a/demos/textedit/textedit.cpp +++ b/demos/textedit/textedit.cpp @@ -262,7 +262,8 @@ void TextEdit::setupEditActions() tb->addAction(a); menu->addAction(a); #ifndef QT_NO_CLIPBOARD - actionPaste->setEnabled(QApplication::clipboard()->mimeData()->hasText()); + if (const QMimeData *md = QApplication::clipboard()->mimeData()) + actionPaste->setEnabled(md->hasText()); #endif } @@ -681,7 +682,8 @@ void TextEdit::cursorPositionChanged() void TextEdit::clipboardDataChanged() { #ifndef QT_NO_CLIPBOARD - actionPaste->setEnabled(QApplication::clipboard()->mimeData()->hasText()); + if (const QMimeData *md = QApplication::clipboard()->mimeData()) + actionPaste->setEnabled(md->hasText()); #endif } -- cgit v0.12 From cb51c2157f870a5c83ae6d9435ec4b1004392bc9 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 13 Dec 2010 22:26:39 +0100 Subject: Don't need to set FD_CLOEXEC since qt_safe_* will have done that. Reviewed-By: Trust Me --- src/network/socket/qnativesocketengine_unix.cpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index f6bfbac..021acd0 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -202,9 +202,6 @@ bool QNativeSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType soc return false; } - // Ensure that the socket is closed on exec*(). - ::fcntl(socket, F_SETFD, FD_CLOEXEC); - socketDescriptor = socket; return true; } @@ -565,16 +562,6 @@ int QNativeSocketEnginePrivate::nativeAccept() #else int acceptedDescriptor = qt_safe_accept(socketDescriptor, 0, 0); #endif - //check if we have valid descriptor at all - if(acceptedDescriptor > 0) { - // Ensure that the socket is closed on exec*() - ::fcntl(acceptedDescriptor, F_SETFD, FD_CLOEXEC); - } -#ifdef Q_OS_SYMBIAN - else { - qWarning("QNativeSocketEnginePrivate::nativeAccept() - acceptedDescriptor <= 0"); - } -#endif return acceptedDescriptor; } -- cgit v0.12 From e1955231478df8990cf8b1f80438abf957c5d6f2 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 14 Dec 2010 11:25:32 +0100 Subject: Add a warning about trying to release a timer ID that isn't active Reviewed-By: Trust Me --- src/corelib/kernel/qeventdispatcher_unix.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/kernel/qeventdispatcher_unix.cpp b/src/corelib/kernel/qeventdispatcher_unix.cpp index f50994c..b2ccc68 100644 --- a/src/corelib/kernel/qeventdispatcher_unix.cpp +++ b/src/corelib/kernel/qeventdispatcher_unix.cpp @@ -501,6 +501,7 @@ bool QTimerInfoList::unregisterTimer(int timerId) } } // id not found + qWarning("Application asked to unregister timer 0x%x which is not registered in this thread. Fix application.", timerId); return false; } -- cgit v0.12 From 038927f1208ff346cbe8d2cfefbd39808ffb5711 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 15 Dec 2010 18:48:05 +0100 Subject: Autotest: Add some comments about this obscure test. More information, see commit d9bf386d917c64ad5d8f11f9daadf82b2be9d531 (old qt-history) and old TT task 90183. Reviewed-By: Trust Me --- tests/auto/qprocess/tst_qprocess.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/auto/qprocess/tst_qprocess.cpp b/tests/auto/qprocess/tst_qprocess.cpp index fd310f4..13f1d26 100644 --- a/tests/auto/qprocess/tst_qprocess.cpp +++ b/tests/auto/qprocess/tst_qprocess.cpp @@ -1999,11 +1999,15 @@ void tst_QProcess::spaceInName() void tst_QProcess::lockupsInStartDetached() { #if !defined(Q_OS_SYMBIAN) - // What exactly is this call supposed to achieve anyway? + // Check that QProcess doesn't cause a lock up at this program's + // exit if a thread was started and we tried to run a program that + // doesn't exist. Before Qt 4.2, this used to lock up on Unix due + // to calling ::exit instead of ::_exit if execve failed. + QHostInfo::lookupHost(QString("something.invalid"), 0, 0); -#endif QProcess::execute("yjhbrty"); QProcess::startDetached("yjhbrty"); +#endif } //----------------------------------------------------------------------------- -- cgit v0.12 From 7b0809edf975f3226b43d3b43b5fe8035298fde9 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 15 Dec 2010 18:48:48 +0100 Subject: ICC: Don't print warning 1259 since it's too annoying. ICC 12 keeps outputting this when you copy a type of larger size to a smaller, or from int to float. --- mkspecs/linux-icc/qmake.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/linux-icc/qmake.conf b/mkspecs/linux-icc/qmake.conf index af56a9a..ba707e23 100644 --- a/mkspecs/linux-icc/qmake.conf +++ b/mkspecs/linux-icc/qmake.conf @@ -23,7 +23,7 @@ QMAKE_YACC = yacc QMAKE_YACCFLAGS = -d QMAKE_CFLAGS = -falign-stack=maintain-16-byte QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -w1 -Wcheck -wd654,1572,411,873,1125 +QMAKE_CFLAGS_WARN_ON = -w1 -Wcheck -wd654,1572,411,873,1125,2259 QMAKE_CFLAGS_WARN_OFF = -w QMAKE_CFLAGS_RELEASE = -O2 -falign-functions=16 -ansi-alias -fstrict-aliasing QMAKE_CFLAGS_DEBUG = -O0 -g -- cgit v0.12 From 981a83d7832e8cd1ee7bcd42dfaba62f0b04f2c1 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 15 Dec 2010 18:53:57 +0100 Subject: Suppress a warning about killing a timer that isn't active. The timer was active, but it got killed by ~QObject. The QObject d-pointer is deleted after the timers (as is expected), which means that the QBasicTimer destructors in QAbstractItemViewPrivate are run after the timers are already gone. Reviewed-by: Trust Me --- src/gui/itemviews/qabstractitemview.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index acc8deb..177b088 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -595,6 +595,8 @@ QAbstractItemView::QAbstractItemView(QAbstractItemViewPrivate &dd, QWidget *pare */ QAbstractItemView::~QAbstractItemView() { + // stop this timer here before ~QObject + d_func()->delayedReset.stop(); } /*! -- cgit v0.12 From fa57982fadab625fb022d32f690ef05427920581 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 16 Dec 2010 11:30:17 +0100 Subject: QmlDebugger: Fix runtime warnings about unregistered metatypes Check whether the type of a property is known to the metatype system before trying to read from it. That avoids lots of runtime warnings e.g. for the QSequentialGroup::currentAnimation property, which type QAbstractAnimation * isn't registered by default via qRegisterMetaType<>(). Reviewed-by: Christiaan Janssen Task-number: QTCREATORBUG-2853 --- src/declarative/qml/qdeclarativeenginedebug.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp index bffe681..e54f7d6 100644 --- a/src/declarative/qml/qdeclarativeenginedebug.cpp +++ b/src/declarative/qml/qdeclarativeenginedebug.cpp @@ -146,7 +146,10 @@ QDeclarativeEngineDebugServer::propertyData(QObject *obj, int propIdx) if (binding) rv.binding = binding->expression(); - QVariant value = prop.read(obj); + QVariant value; + if (prop.userType() != 0) { + value = prop.read(obj); + } rv.value = valueContents(value); if (QDeclarativeValueTypeFactory::isValueType(prop.userType())) { -- cgit v0.12 From 6f9642572c392536c07a52037e4c1de587489c49 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 16 Dec 2010 13:21:22 +0100 Subject: Add work around for bug when painting w/glTexSubImage into large texture It seems that copying small rectangles from glTexSubImage2D into a texture which is 2048x2048 is busted on some SGX drivers, even though the driver reports 2048 as the maximum texture size. This caused text to turn into flickering garbage once the texture glyph cache had grown to its max size (e.g. when painting very many Chinese glyphs.) To work around the problem, we hardcore the maximum texture height to 1024 on this driver so that the texture glyph cache is reset whenever that size is exceeded. Task-number: QT-3971 Done-with: Samuel --- src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp | 5 ++++- src/opengl/qgl.cpp | 1 + src/opengl/qgl_egl.cpp | 2 ++ src/opengl/qgl_p.h | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp index 1b879c3..ba311c3 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp @@ -323,6 +323,9 @@ int QGLTextureGlyphCache::maxTextureWidth() const int QGLTextureGlyphCache::maxTextureHeight() const { - return ctx->d_ptr->maxTextureSize(); + if (ctx->d_ptr->workaround_brokenTexSubImage) + return qMin(1024, ctx->d_ptr->maxTextureSize()); + else + return ctx->d_ptr->maxTextureSize(); } QT_END_NAMESPACE diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 18f1203..9bf879a 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1706,6 +1706,7 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format) active_engine = 0; workaround_needsFullClearOnEveryFrame = false; workaround_brokenFBOReadBack = false; + workaround_brokenTexSubImage = false; workaroundsCached = false; workaround_brokenTextureFromPixmap = false; diff --git a/src/opengl/qgl_egl.cpp b/src/opengl/qgl_egl.cpp index 8902099..6f9e39c 100644 --- a/src/opengl/qgl_egl.cpp +++ b/src/opengl/qgl_egl.cpp @@ -204,6 +204,8 @@ void QGLContext::makeCurrent() const char *egl_version = eglQueryString(d->eglContext->display(), EGL_VERSION); if (egl_version && strstr(egl_version, "1.3")) d->workaround_brokenFBOReadBack = true; + else if (egl_version && strstr(egl_version, "1.4")) + d->workaround_brokenTexSubImage = true; } } } diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index b46d428..bf830ba 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -401,6 +401,7 @@ public: // workarounds for driver/hw bugs on different platforms uint workaround_needsFullClearOnEveryFrame : 1; uint workaround_brokenFBOReadBack : 1; + uint workaround_brokenTexSubImage : 1; uint workaroundsCached : 1; uint workaround_brokenTextureFromPixmap : 1; -- cgit v0.12 From ab8a9e77d877fd53eaec8dca1eeca619a4ba81d6 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 16 Dec 2010 12:57:06 +0200 Subject: Avoid duplicate resize event No need to have two resize events in queue for same widget, so do not post a new one if one is already pending in QSymbianControl::SizeChanged(). Reviewed-by: Sami Merila --- src/gui/kernel/qapplication_s60.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 6db1fa8..181fcc7 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -1174,8 +1174,10 @@ void QSymbianControl::SizeChanged() if (!slowResize && tlwExtra) tlwExtra->inTopLevelResize = false; } else { - QResizeEvent *e = new QResizeEvent(newSize, oldSize); - QApplication::postEvent(qwidget, e); + if (!qwidget->testAttribute(Qt::WA_PendingResizeEvent)) { + QResizeEvent *e = new QResizeEvent(newSize, oldSize); + QApplication::postEvent(qwidget, e); + } } } -- cgit v0.12 From f0347c8c0c37bd90dcaefb8f4b669096f7eb66b5 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 16 Dec 2010 15:23:51 +0200 Subject: Improved orientation change autotest The test wasn't even compiling anymore, so fixed that. Also added additional orientation change and an available geometry check after each orientation change. Reviewed-by: Sami Merila --- .../orientationchange/orientationchange.pro | 1 + .../orientationchange/tst_orientationchange.cpp | 43 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/tests/auto/symbian/orientationchange/orientationchange.pro b/tests/auto/symbian/orientationchange/orientationchange.pro index 08b34f9..98aa2ad 100644 --- a/tests/auto/symbian/orientationchange/orientationchange.pro +++ b/tests/auto/symbian/orientationchange/orientationchange.pro @@ -4,4 +4,5 @@ SOURCES += tst_orientationchange.cpp symbian { INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE + LIBS += -lcone -leikcore -lavkon # Screen orientation } diff --git a/tests/auto/symbian/orientationchange/tst_orientationchange.cpp b/tests/auto/symbian/orientationchange/tst_orientationchange.cpp index eb3709d..2ac2f7f 100644 --- a/tests/auto/symbian/orientationchange/tst_orientationchange.cpp +++ b/tests/auto/symbian/orientationchange/tst_orientationchange.cpp @@ -45,6 +45,8 @@ #include #include +#include +#include class tst_orientationchange : public QObject { @@ -151,6 +153,47 @@ void tst_orientationchange::resizeEventOnOrientationChange() } QCOMPARE(normalWidget->resizeEventCount, 0); + QDesktopWidget desktop; + QRect qtAvail = desktop.availableGeometry(normalWidget); + TRect clientRect = static_cast(CCoeEnv::Static()-> AppUi())->ClientRect(); + QRect symbianAvail = qt_TRect2QRect(clientRect); + QCOMPARE(qtAvail, symbianAvail); + + // Switch orientation back to original + orientation = orientation == CAknAppUi::EAppUiOrientationPortrait + ? CAknAppUi::EAppUiOrientationLandscape + : CAknAppUi::EAppUiOrientationPortrait; + + + fullScreenWidget->reset(); + maximizedWidget->reset(); + normalWidget->reset(); + + TRAP(err, appUi->SetOrientationL(orientation)); + + QCoreApplication::sendPostedEvents(); + QCoreApplication::sendPostedEvents(); + + // setOrientationL is not guaranteed to change orientation + // (if emulator configured to support just portrait or landscape, then + // setOrientationL call shouldn't do anything). + // So let's ensure that we do not get resize event twice. + + QVERIFY(fullScreenWidget->resizeEventCount <= 1); + if (fullScreenWidget->resizeEventCount) { + QCOMPARE(fullScreenWidget->size(), fullScreenWidget->resizeEventSize); + } + QVERIFY(maximizedWidget->resizeEventCount <= 1); + if (fullScreenWidget->resizeEventCount) { + QCOMPARE(maximizedWidget->size(), maximizedWidget->resizeEventSize); + } + QCOMPARE(normalWidget->resizeEventCount, 0); + + qtAvail = desktop.availableGeometry(normalWidget); + clientRect = static_cast(CCoeEnv::Static()-> AppUi())->ClientRect(); + symbianAvail = qt_TRect2QRect(clientRect); + QCOMPARE(qtAvail, symbianAvail); + TRAP(err, appUi->SetOrientationL(CAknAppUi::EAppUiOrientationUnspecified)); delete normalWidget; -- cgit v0.12 From 7857e0cf4673fb0defab5af9c60d0c2dea93e55c Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 15 Dec 2010 18:55:48 +0100 Subject: Doc: typo fixed in doc/src/declarative/extending.qdoc Reviewed-by: TrustMe --- doc/src/declarative/extending.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/declarative/extending.qdoc b/doc/src/declarative/extending.qdoc index e23ca91..748ec6c 100644 --- a/doc/src/declarative/extending.qdoc +++ b/doc/src/declarative/extending.qdoc @@ -461,7 +461,7 @@ constructing an animation object and manually setting the animation's "target" property, a property value source can be assigned directly to a property of any type and automatically set up this association. -The example shown here is rather contrived: the \c announcment property of the +The example shown here is rather contrived: the \c announcement property of the \c BirthdayParty object is a string that is printed every time it is assigned and the \c HappyBirthdaySong value source generates the lyrics of the song "Happy Birthday". -- cgit v0.12 From 632016368e26ba06d7d09740a8a1805f4ea911f1 Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Fri, 17 Dec 2010 15:24:30 +1000 Subject: Update test bitmaps for QDeclarativeImage::svg() autotest on Linux Task-number: Reviewed-by: Martin Jones --- .../declarative/qdeclarativeimage/data/heart.png | Bin 12424 -> 12577 bytes .../declarative/qdeclarativeimage/data/heart200.png | Bin 7943 -> 8063 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart.png b/tests/auto/declarative/qdeclarativeimage/data/heart.png index ff93f6c..abe97fe 100644 Binary files a/tests/auto/declarative/qdeclarativeimage/data/heart.png and b/tests/auto/declarative/qdeclarativeimage/data/heart.png differ diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart200.png b/tests/auto/declarative/qdeclarativeimage/data/heart200.png index 5a31ae8..7fbb13c 100644 Binary files a/tests/auto/declarative/qdeclarativeimage/data/heart200.png and b/tests/auto/declarative/qdeclarativeimage/data/heart200.png differ -- cgit v0.12 From e0abcb2ff7a3044305580659f9a432a9630a5943 Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Fri, 17 Dec 2010 16:18:03 +1000 Subject: Fix QDeclarativeState::reset() autotest Current state reset mechanism does not really work for Text elements as the keeping implicit correct would require relayouting of text twice (See bug QTBUG-15118). Changed QDeclarativeState reset autotest to use Image element instead of Text element until the issue has been fixed. Task-number: Reviewed-by: Yann Bodson --- tests/auto/declarative/qdeclarativestates/data/image.png | Bin 0 -> 173 bytes tests/auto/declarative/qdeclarativestates/data/reset.qml | 9 ++++----- .../qdeclarativestates/tst_qdeclarativestates.cpp | 13 ++++++------- 3 files changed, 10 insertions(+), 12 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativestates/data/image.png diff --git a/tests/auto/declarative/qdeclarativestates/data/image.png b/tests/auto/declarative/qdeclarativestates/data/image.png new file mode 100644 index 0000000..ed1833c Binary files /dev/null and b/tests/auto/declarative/qdeclarativestates/data/image.png differ diff --git a/tests/auto/declarative/qdeclarativestates/data/reset.qml b/tests/auto/declarative/qdeclarativestates/data/reset.qml index 8799c97..a140ffa 100644 --- a/tests/auto/declarative/qdeclarativestates/data/reset.qml +++ b/tests/auto/declarative/qdeclarativestates/data/reset.qml @@ -3,17 +3,16 @@ import QtQuick 1.0 Rectangle { width: 640 height: 480 - Text { - id: theText + Image { + id: image width: 40 - wrapMode: Text.WordWrap - text: "a text string that is longer than 40 pixels" + source: "image.png" } states: State { name: "state1" PropertyChanges { - target: theText + target: image width: undefined } } diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp index b8409a5..870842c 100644 --- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp +++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp @@ -44,7 +44,6 @@ #include #include #include -#include #include #include #include @@ -1126,15 +1125,15 @@ void tst_qdeclarativestates::reset() QDeclarativeRectangle *rect = qobject_cast(c.create()); QVERIFY(rect != 0); - QDeclarativeText *text = rect->findChild(); - QVERIFY(text != 0); - QCOMPARE(text->width(), qreal(40.)); - QVERIFY(text->width() < text->height()); + QDeclarativeImage *image = rect->findChild(); + QVERIFY(image != 0); + QCOMPARE(image->width(), qreal(40.)); + QCOMPARE(image->height(), qreal(20.)); QDeclarativeItemPrivate::get(rect)->setState("state1"); - QVERIFY(text->width() > 41); - QVERIFY(text->width() > text->height()); + QCOMPARE(image->width(), 20.0); + QCOMPARE(image->height(), qreal(20.)); } void tst_qdeclarativestates::illegalObjectCreation() -- cgit v0.12 From 80eb3ebbfe24738163532494e8866ac20fd1b0e4 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 16 Dec 2010 16:03:13 +0200 Subject: Fix incorrect file name case for OpenGL libraries in symbian.conf. To support linux builds, file names must be cased correctly. Task-number: QT-4375 Reviewed-by: Miikka Heikkinen --- mkspecs/common/symbian/symbian.conf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mkspecs/common/symbian/symbian.conf b/mkspecs/common/symbian/symbian.conf index 707335c..00cf0d7 100644 --- a/mkspecs/common/symbian/symbian.conf +++ b/mkspecs/common/symbian/symbian.conf @@ -70,12 +70,12 @@ QMAKE_LIBS_CORE = $$QMAKE_LIBS -lefsrv -lhal -lbafl QMAKE_LIBS_GUI = $$QMAKE_LIBS_CORE -lfbscli -lbitgdi -lgdi -lws32 -lapgrfx -lcone -leikcore -lmediaclientaudio -lapparc -lcentralrepository QMAKE_LIBS_NETWORK = QMAKE_LIBS_EGL = -llibEGL -QMAKE_LIBS_OPENGL = -llibglesv2 +QMAKE_LIBS_OPENGL = -llibGLESv2 QMAKE_LIBS_OPENGL_ES1 = -llibGLESv1_CM -QMAKE_LIBS_OPENGL_ES2 = -llibglesv2 -QMAKE_LIBS_OPENGL_QT = -llibglesv2 -lcone -lws32 +QMAKE_LIBS_OPENGL_ES2 = -llibGLESv2 +QMAKE_LIBS_OPENGL_QT = -llibGLESv2 -lcone -lws32 QMAKE_LIBS_OPENGL_ES1_QT = -llibGLESv1_CM -lcone -lws32 -QMAKE_LIBS_OPENGL_ES2_QT = -llibglesv2 -lcone -lws32 +QMAKE_LIBS_OPENGL_ES2_QT = -llibGLESv2 -lcone -lws32 QMAKE_LIBS_OPENVG = -llibOpenVG -lfbscli -lbitgdi -lgdi QMAKE_LIBS_THREAD = -llibpthread QMAKE_LIBS_COMPAT = -- cgit v0.12 From d238b0ba236da4c3c33c0707d8dd6f5e5903d6c0 Mon Sep 17 00:00:00 2001 From: Ville Pernu Date: Fri, 17 Dec 2010 11:08:53 +0200 Subject: Fix waitForOpened not working with already active configuration When an active QNetworkConfiguration is already in use (e.g. browser already open), the QNetworkSession::waitForOpened() did not work properly. Changed one if-statement in the function to adapt to the scenario. Reviewed-by: Perttu Pohjonen Task-number: QTBUG-565 --- src/network/bearer/qnetworksession.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/network/bearer/qnetworksession.cpp b/src/network/bearer/qnetworksession.cpp index 226c3c5..db1a37c 100644 --- a/src/network/bearer/qnetworksession.cpp +++ b/src/network/bearer/qnetworksession.cpp @@ -310,8 +310,9 @@ bool QNetworkSession::waitForOpened(int msecs) if (d->isOpen) return true; - if (d->state != Connecting) + if (!(d->state == Connecting || d->state == Connected)) { return false; + } QEventLoop* loop = new QEventLoop(this); QObject::connect(d, SIGNAL(quitPendingWaitsForOpened()), -- cgit v0.12 From b54efea2e97baac1d9442e829be2d6fb322c5085 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Fri, 17 Dec 2010 11:37:52 +0200 Subject: Use relative include instead of absolute in default qmake.conf Absolute include path breaks QtP releases which copy mkspecs under epoc32 and do not necessarily have the sources available in the original absolute path and can't patch the paths either at installation time. Task-number: QTBUG-16172 Reviewed-by: Oswald Buddenhagen --- tools/configure/configureapp.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index c967dad..915a56d 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -3267,8 +3267,14 @@ void Configure::generateConfigfiles() if (qmakeConfFile.open(QFile::WriteOnly | QFile::Text)) { QTextStream qmakeConfStream; qmakeConfStream.setDevice(&qmakeConfFile); + // While QMAKESPEC_ORIGINAL being relative or absolute doesn't matter for the + // primary use of this variable by qmake to identify the original mkspec, the + // variable is also used for few special cases where the absolute path is required. + // Conversely, the include of the original qmake.conf must be done using relative path, + // as some Qt binary deployments are done in a manner that doesn't allow for patching + // the paths at the installation time. qmakeConfStream << "QMAKESPEC_ORIGINAL=" << pltSpec << endl << endl; - qmakeConfStream << "include(" << pltSpec << "/qmake.conf)" << endl; + qmakeConfStream << "include(" << "../" << spec << "/qmake.conf)" << endl << endl; qmakeConfStream.flush(); qmakeConfFile.close(); } -- cgit v0.12 From 184458394b344947bea1852ab88561dc60db6038 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Mon, 20 Dec 2010 10:32:54 +1000 Subject: Quiet unused parameter warnings. --- src/plugins/bearer/icd/qicdengine.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/bearer/icd/qicdengine.cpp b/src/plugins/bearer/icd/qicdengine.cpp index a5a183b..96827f3 100644 --- a/src/plugins/bearer/icd/qicdengine.cpp +++ b/src/plugins/bearer/icd/qicdengine.cpp @@ -966,6 +966,9 @@ void QIcdEngine::connectionStateSignalsSlot(QDBusMessage msg) void QIcdEngine::icdServiceOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner) { + Q_UNUSED(serviceName); + Q_UNUSED(oldOwner); + QMutexLocker locker(&mutex); if (newOwner.isEmpty()) { -- cgit v0.12 From 95b0418a7ee7aee9658fd19b363e73d583af0b04 Mon Sep 17 00:00:00 2001 From: Damian Jansen Date: Mon, 20 Dec 2010 13:09:48 +1000 Subject: Fix deployment of minehunt for Symbian Task: QT-4298 --- demos/declarative/minehunt/minehunt.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/declarative/minehunt/minehunt.pro b/demos/declarative/minehunt/minehunt.pro index 8a7fdc5..5929ecf 100644 --- a/demos/declarative/minehunt/minehunt.pro +++ b/demos/declarative/minehunt/minehunt.pro @@ -18,6 +18,6 @@ symbian:{ TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) qmlminehuntfiles.sources = MinehuntCore minehunt.qml - DEPLOYMENT = qmlminehuntfiles + DEPLOYMENT += qmlminehuntfiles } -- cgit v0.12 From 0aeebdc851682d2afd63494ddeafa4e745ad2b72 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 20 Dec 2010 14:30:09 +1000 Subject: Update docs on importing javascript files --- doc/src/declarative/javascriptblocks.qdoc | 4 +++- doc/src/declarative/modules.qdoc | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/src/declarative/javascriptblocks.qdoc b/doc/src/declarative/javascriptblocks.qdoc index 155bd6e..68cb392 100644 --- a/doc/src/declarative/javascriptblocks.qdoc +++ b/doc/src/declarative/javascriptblocks.qdoc @@ -99,7 +99,9 @@ resource, the component's \l {QDeclarativeComponent::status()}{status} is set to Imported JavaScript files are always qualified using the "as" keyword. The qualifier for JavaScript files must be unique, so there is always a one-to-one -mapping between qualifiers and JavaScript files. +mapping between qualifiers and JavaScript files. (This also means qualifiers cannot +be named the same as built-in JavaScript objects such as \c Date and \c Math). + \section2 Code-Behind Implementation Files diff --git a/doc/src/declarative/modules.qdoc b/doc/src/declarative/modules.qdoc index 011eb63..bf9f5fd 100644 --- a/doc/src/declarative/modules.qdoc +++ b/doc/src/declarative/modules.qdoc @@ -216,6 +216,8 @@ JavaScript files must always be imported with a named import: } \endqml +The qualifier ("MyScript" in the above example) must be unique within the QML document. +Unlike ordinary modules, multiple scripts cannot be imported into the same namespace. \section1 Writing a qmldir file -- cgit v0.12 From 327169a6a3fb0bac258cb878019734211a707cce Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 20 Dec 2010 14:30:27 +1000 Subject: Don't truncate image:// url strings prematurely Url fragments and queries were being removed from the image ids passed to QDeclarativeImageProvider. Task-number: QTBUG-16195 Reviewed-by: Martin Jones --- src/declarative/qml/qdeclarativeengine.cpp | 12 ++++-- src/declarative/qml/qdeclarativeimageprovider.cpp | 16 ++++++-- .../tst_qdeclarativeimageprovider.cpp | 46 ++++++++++++++++++++-- 3 files changed, 62 insertions(+), 12 deletions(-) diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 201e675..cf3ea42 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -760,8 +760,10 @@ QImage QDeclarativeEnginePrivate::getImageFromProvider(const QUrl &url, QSize *s QImage image; QSharedPointer provider = imageProviders.value(url.host()); locker.unlock(); - if (provider) - image = provider->requestImage(url.path().mid(1), size, req_size); + if (provider) { + QString imageId = url.toString(QUrl::RemoveScheme | QUrl::RemoveAuthority).mid(1); + image = provider->requestImage(imageId, size, req_size); + } return image; } @@ -771,8 +773,10 @@ QPixmap QDeclarativeEnginePrivate::getPixmapFromProvider(const QUrl &url, QSize QPixmap pixmap; QSharedPointer provider = imageProviders.value(url.host()); locker.unlock(); - if (provider) - pixmap = provider->requestPixmap(url.path().mid(1), size, req_size); + if (provider) { + QString imageId = url.toString(QUrl::RemoveScheme | QUrl::RemoveAuthority).mid(1); + pixmap = provider->requestPixmap(imageId, size, req_size); + } return pixmap; } diff --git a/src/declarative/qml/qdeclarativeimageprovider.cpp b/src/declarative/qml/qdeclarativeimageprovider.cpp index ef31be7..e3da645 100644 --- a/src/declarative/qml/qdeclarativeimageprovider.cpp +++ b/src/declarative/qml/qdeclarativeimageprovider.cpp @@ -182,13 +182,17 @@ QDeclarativeImageProvider::ImageType QDeclarativeImageProvider::imageType() cons Implement this method to return the image with \a id. The default implementation returns an empty image. + The \a id is the requested image source, with the "image:" scheme and + provider identifier removed. For example, if the image \l{Image::}{source} + was "image://myprovider/icons/home", the given \a id would be "icons/home". + The \a requestedSize corresponds to the \l {Image::sourceSize} requested by an Image element. If \a requestedSize is a valid size, the image returned should be of that size. In all cases, \a size must be set to the original size of the image. This - is used to set the \l {Item::}{width} and \l {Item::}{height} of image - elements that should be automatically sized to the loaded image. + is used to set the \l {Item::}{width} and \l {Item::}{height} of the + relevant \l Image if these values have not been set explicitly. \note this method may be called by multiple threads, so ensure the implementation of this method is reentrant. @@ -207,13 +211,17 @@ QImage QDeclarativeImageProvider::requestImage(const QString &id, QSize *size, c Implement this method to return the pixmap with \a id. The default implementation returns an empty pixmap. + The \a id is the requested image source, with the "image:" scheme and + provider identifier removed. For example, if the image \l{Image::}{source} + was "image://myprovider/icons/home", the given \a id would be "icons/home". + The \a requestedSize corresponds to the \l {Image::sourceSize} requested by an Image element. If \a requestedSize is a valid size, the image returned should be of that size. In all cases, \a size must be set to the original size of the image. This - is used to set the \l {Item::}{width} and \l {Item::}{height} of image - elements that should be automatically sized to the loaded image. + is used to set the \l {Item::}{width} and \l {Item::}{height} of the + relevant \l Image if these values have not been set explicitly. */ QPixmap QDeclarativeImageProvider::requestPixmap(const QString &id, QSize *size, const QSize& requestedSize) { diff --git a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp index cd12e3a..5b214e6 100644 --- a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp +++ b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp @@ -100,6 +100,8 @@ public: QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize) { + lastImageId = id; + if (id == QLatin1String("no-such-file.png")) return QImage(); @@ -114,6 +116,7 @@ public: } bool *deleteWatch; + QString lastImageId; }; Q_DECLARE_METATYPE(TestQImageProvider*); @@ -134,6 +137,8 @@ public: QPixmap requestPixmap(const QString &id, QSize *size, const QSize& requestedSize) { + lastImageId = id; + if (id == QLatin1String("no-such-file.png")) return QPixmap(); @@ -148,6 +153,7 @@ public: } bool *deleteWatch; + QString lastImageId; }; Q_DECLARE_METATYPE(TestQPixmapProvider*); @@ -164,22 +170,49 @@ QString tst_qdeclarativeimageprovider::newImageFileName() const void tst_qdeclarativeimageprovider::fillRequestTestsData(const QString &id) { QTest::addColumn("source"); + QTest::addColumn("imageId"); QTest::addColumn("properties"); QTest::addColumn("size"); QTest::addColumn("error"); - QTest::newRow(QTest::toString(id + " exists")) << newImageFileName() << "" << QSize(100,100) << ""; - QTest::newRow(QTest::toString(id + " scaled")) << newImageFileName() << "sourceSize: \"80x30\"" << QSize(80,30) << ""; + QString fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " simple test")) + << "image://test/" + fileName << fileName << "" << QSize(100,100) << ""; + + fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " url with no id")) + << "image://test/" + fileName << "" + fileName << "" << QSize(100,100) << ""; + + fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " url with path")) + << "image://test/test/path" + fileName << "test/path" + fileName << "" << QSize(100,100) << ""; + + fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " url with fragment")) + << "image://test/faq.html?#question13" + fileName << "faq.html?#question13" + fileName << "" << QSize(100,100) << ""; - QTest::newRow(QTest::toString(id + " missing")) << "image://test/no-such-file.png" << "" << QSize() + fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " url with query")) + << "image://test/cgi-bin/drawgraph.cgi?type=pie&color=green" + fileName << "cgi-bin/drawgraph.cgi?type=pie&color=green" + fileName + << "" << QSize(100,100) << ""; + + fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " scaled image")) + << "image://test/" + fileName << fileName << "sourceSize: \"80x30\"" << QSize(80,30) << ""; + + QTest::newRow(QTest::toString(id + " missing")) + << "image://test/no-such-file.png" << "no-such-file.png" << "" << QSize(100,100) << "file::2:1: QML Image: Failed to get image from provider: image://test/no-such-file.png"; - QTest::newRow(QTest::toString(id + " unknown provider")) << "image://bogus/exists.png" << "" << QSize() + + QTest::newRow(QTest::toString(id + " unknown provider")) + << "image://bogus/exists.png" << "" << "" << QSize() << "file::2:1: QML Image: Failed to get image from provider: image://bogus/exists.png"; } void tst_qdeclarativeimageprovider::runTest(bool async, QDeclarativeImageProvider *provider) { QFETCH(QString, source); + QFETCH(QString, imageId); QFETCH(QString, properties); QFETCH(QSize, size); QFETCH(QString, error); @@ -210,6 +243,11 @@ void tst_qdeclarativeimageprovider::runTest(bool async, QDeclarativeImageProvide QTRY_VERIFY(obj->status() == QDeclarativeImage::Ready); else QVERIFY(obj->status() == QDeclarativeImage::Ready); + if (QByteArray(QTest::currentDataTag()).startsWith("qimage")) + QCOMPARE(static_cast(provider)->lastImageId, imageId); + else + QCOMPARE(static_cast(provider)->lastImageId, imageId); + QCOMPARE(obj->width(), qreal(size.width())); QCOMPARE(obj->height(), qreal(size.height())); QCOMPARE(obj->pixmap().width(), size.width()); -- cgit v0.12 From 95e64de1827f9b2bae829d40756f7142c56c460f Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Mon, 20 Dec 2010 15:44:25 +1000 Subject: Update test bitmaps for QDeclarativeImage::svg() autotest on Windows Task-number: Reviewed-by: Martin Jones --- .../qdeclarativeimage/data/heart-win32.png | Bin 12457 -> 12621 bytes .../qdeclarativeimage/data/heart200-win32.png | Bin 7939 -> 8062 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart-win32.png b/tests/auto/declarative/qdeclarativeimage/data/heart-win32.png index 5992e79..351da13 100644 Binary files a/tests/auto/declarative/qdeclarativeimage/data/heart-win32.png and b/tests/auto/declarative/qdeclarativeimage/data/heart-win32.png differ diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart200-win32.png b/tests/auto/declarative/qdeclarativeimage/data/heart200-win32.png index 19b20a8..4976ff9 100644 Binary files a/tests/auto/declarative/qdeclarativeimage/data/heart200-win32.png and b/tests/auto/declarative/qdeclarativeimage/data/heart200-win32.png differ -- cgit v0.12 From 197ec350e4014330851a013501c6dde3068ac26f Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Mon, 20 Dec 2010 17:07:34 +1000 Subject: Setting TextInput.cursorPosition outside bounds crashed. Check bounds in TextInput and TextEdit. Task-number: QTBUG-16188 Reviewed-by: Bea Lam --- src/declarative/graphicsitems/qdeclarativetextedit.cpp | 2 ++ src/declarative/graphicsitems/qdeclarativetextinput.cpp | 2 ++ .../qdeclarativetextedit/tst_qdeclarativetextedit.cpp | 13 +++++++++++++ .../qdeclarativetextinput/tst_qdeclarativetextinput.cpp | 13 +++++++++++++ 4 files changed, 30 insertions(+) diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index e05f4e4..4e16d24 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -643,6 +643,8 @@ int QDeclarativeTextEdit::cursorPosition() const void QDeclarativeTextEdit::setCursorPosition(int pos) { Q_D(QDeclarativeTextEdit); + if (pos < 0 || pos > d->text.length()) + return; QTextCursor cursor = d->control->textCursor(); if (cursor.position() == pos) return; diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index df103de..521e4ab 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -437,6 +437,8 @@ int QDeclarativeTextInput::cursorPosition() const void QDeclarativeTextInput::setCursorPosition(int cp) { Q_D(QDeclarativeTextInput); + if (cp < 0 || cp > d->control->text().length()) + return; d->control->moveCursor(cp); } diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index a7971cc..c7a51f7 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -652,6 +652,19 @@ void tst_qdeclarativetextedit::selection() QVERIFY(textEditObject->selectionEnd() == 0); QVERIFY(textEditObject->selectedText().isNull()); + // Verify invalid positions are ignored. + textEditObject->setCursorPosition(-1); + QVERIFY(textEditObject->cursorPosition() == 0); + QVERIFY(textEditObject->selectionStart() == 0); + QVERIFY(textEditObject->selectionEnd() == 0); + QVERIFY(textEditObject->selectedText().isNull()); + + textEditObject->setCursorPosition(textEditObject->text().count()+1); + QVERIFY(textEditObject->cursorPosition() == 0); + QVERIFY(textEditObject->selectionStart() == 0); + QVERIFY(textEditObject->selectionEnd() == 0); + QVERIFY(textEditObject->selectedText().isNull()); + //Test selection for(int i=0; i<= testStr.size(); i++) { textEditObject->select(0,i); diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index 76e0102..7b2310a 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -354,6 +354,19 @@ void tst_qdeclarativetextinput::selection() QVERIFY(textinputObject->selectionEnd() == 0); QVERIFY(textinputObject->selectedText().isNull()); + // Verify invalid positions are ignored. + textinputObject->setCursorPosition(-1); + QVERIFY(textinputObject->cursorPosition() == 0); + QVERIFY(textinputObject->selectionStart() == 0); + QVERIFY(textinputObject->selectionEnd() == 0); + QVERIFY(textinputObject->selectedText().isNull()); + + textinputObject->setCursorPosition(textinputObject->text().count()+1); + QVERIFY(textinputObject->cursorPosition() == 0); + QVERIFY(textinputObject->selectionStart() == 0); + QVERIFY(textinputObject->selectionEnd() == 0); + QVERIFY(textinputObject->selectedText().isNull()); + //Test selection for(int i=0; i<= testStr.size(); i++) { textinputObject->select(0,i); -- cgit v0.12 From cb44818623d10d5d6a9f49ddf5651351ebe55f67 Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Mon, 20 Dec 2010 14:40:51 +0100 Subject: Fix the redirection of painting for the toolbar. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-16154 Reviewed-by: Samuel Rødal --- src/gui/painting/qunifiedtoolbarsurface_mac.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/painting/qunifiedtoolbarsurface_mac.cpp b/src/gui/painting/qunifiedtoolbarsurface_mac.cpp index ace0a46..02ba8db 100644 --- a/src/gui/painting/qunifiedtoolbarsurface_mac.cpp +++ b/src/gui/painting/qunifiedtoolbarsurface_mac.cpp @@ -83,11 +83,11 @@ void QUnifiedToolbarSurface::recursiveRedirect(QObject *object, const QPoint &of widget->d_func()->unifiedSurface = this; widget->d_func()->isInUnifiedToolbar = true; widget->d_func()->toolbar_offset = offset; - } - } - for (int i = 0; i < object->children().size(); ++i) { - recursiveRedirect(object->children().at(i), offset); + for (int i = 0; i < object->children().size(); ++i) { + recursiveRedirect(object->children().at(i), offset); + } + } } } } -- cgit v0.12 From 6d6c738879bb2ef5b5c1e42908bdd1ed16980f95 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Wed, 1 Dec 2010 12:13:27 +0300 Subject: use binary search int the string2PaperSize() helper since it is much much faster Merge-request: 2516 Signed-off-by: axis --- src/gui/painting/qprinterinfo_unix.cpp | 207 ++++++++++----------------------- 1 file changed, 64 insertions(+), 143 deletions(-) diff --git a/src/gui/painting/qprinterinfo_unix.cpp b/src/gui/painting/qprinterinfo_unix.cpp index 2129aa5..0d4cc16 100644 --- a/src/gui/painting/qprinterinfo_unix.cpp +++ b/src/gui/painting/qprinterinfo_unix.cpp @@ -60,6 +60,68 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_PRINTER +#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) +// preserver names in ascending order for the binary search +static const struct NamedPaperSize { + const char *const name; + QPrinter::PaperSize size; +} named_sizes_map[QPrinter::NPageSize] = { + { "A0", QPrinter::A0 }, + { "A1", QPrinter::A1 }, + { "A2", QPrinter::A2 }, + { "A3", QPrinter::A3 }, + { "A4", QPrinter::A4 }, + { "A5", QPrinter::A5 }, + { "A6", QPrinter::A6 }, + { "A7", QPrinter::A7 }, + { "A8", QPrinter::A8 }, + { "A9", QPrinter::A9 }, + { "B0", QPrinter::B0 }, + { "B1", QPrinter::B1 }, + { "B10", QPrinter::B10 }, + { "B2", QPrinter::B2 }, + { "B4", QPrinter::B4 }, + { "B5", QPrinter::B5 }, + { "B6", QPrinter::B6 }, + { "B7", QPrinter::B7 }, + { "B8", QPrinter::B8 }, + { "B9", QPrinter::B9 }, + { "C5E", QPrinter::C5E }, + { "Comm10E", QPrinter::Comm10E }, + { "Custom", QPrinter::Custom }, + { "DLE", QPrinter::DLE }, + { "Executive", QPrinter::Executive }, + { "Folio", QPrinter::Folio }, + { "Ledger", QPrinter::Ledger }, + { "Legal", QPrinter::Legal }, + { "Letter", QPrinter::Letter }, + { "Tabloid", QPrinter::Tabloid } +}; + +inline bool operator<(const char *name, const NamedPaperSize &data) +{ return qstrcmp(name, data.name) < 0; } +inline bool operator<(const NamedPaperSize &data, const char *name) +{ return qstrcmp(data.name, name) < 0; } + +static inline QPrinter::PaperSize string2PaperSize(const char *name) +{ + const NamedPaperSize *r = qBinaryFind(named_sizes_map, named_sizes_map + QPrinter::NPageSize, name); + if (r - named_sizes_map != QPrinter::NPageSize) + return r->size; + return QPrinter::Custom; +} + +static inline const char *paperSize2String(QPrinter::PaperSize size) +{ + for (int i = 0; i < QPrinter::NPageSize; ++i) { + if (size == named_sizes_map[i].size) + return named_sizes_map[i].name; + } + return 0; +} +#endif + + class QPrinterInfoPrivate { Q_DECLARE_PUBLIC(QPrinterInfo) @@ -68,9 +130,6 @@ public: QPrinterInfoPrivate(const QString& name); ~QPrinterInfoPrivate(); - static QPrinter::PaperSize string2PaperSize(const QString& str); - static QString pageSize2String(QPrinter::PaperSize size); - private: QString m_name; bool m_isNull; @@ -977,11 +1036,8 @@ QList< QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const cups.setCurrentPrinter(d->m_cupsPrinterIndex); const ppd_option_t* sizes = cups.pageSizes(); if (sizes) { - for (int j = 0; j < sizes->num_choices; ++j) { - d->m_paperSizes.append( - QPrinterInfoPrivate::string2PaperSize( - QLatin1String(sizes->choices[j].choice))); - } + for (int j = 0; j < sizes->num_choices; ++j) + d->m_paperSizes.append(string2PaperSize(sizes->choices[j].choice)); } } #endif @@ -1016,141 +1072,6 @@ QPrinterInfoPrivate::~QPrinterInfoPrivate() { } -QPrinter::PaperSize QPrinterInfoPrivate::string2PaperSize(const QString& str) -{ - if (str == QLatin1String("A4")) { - return QPrinter::A4; - } else if (str == QLatin1String("B5")) { - return QPrinter::B5; - } else if (str == QLatin1String("Letter")) { - return QPrinter::Letter; - } else if (str == QLatin1String("Legal")) { - return QPrinter::Legal; - } else if (str == QLatin1String("Executive")) { - return QPrinter::Executive; - } else if (str == QLatin1String("A0")) { - return QPrinter::A0; - } else if (str == QLatin1String("A1")) { - return QPrinter::A1; - } else if (str == QLatin1String("A2")) { - return QPrinter::A2; - } else if (str == QLatin1String("A3")) { - return QPrinter::A3; - } else if (str == QLatin1String("A5")) { - return QPrinter::A5; - } else if (str == QLatin1String("A6")) { - return QPrinter::A6; - } else if (str == QLatin1String("A7")) { - return QPrinter::A7; - } else if (str == QLatin1String("A8")) { - return QPrinter::A8; - } else if (str == QLatin1String("A9")) { - return QPrinter::A9; - } else if (str == QLatin1String("B0")) { - return QPrinter::B0; - } else if (str == QLatin1String("B1")) { - return QPrinter::B1; - } else if (str == QLatin1String("B10")) { - return QPrinter::B10; - } else if (str == QLatin1String("B2")) { - return QPrinter::B2; - } else if (str == QLatin1String("B3")) { - return QPrinter::B3; - } else if (str == QLatin1String("B4")) { - return QPrinter::B4; - } else if (str == QLatin1String("B6")) { - return QPrinter::B6; - } else if (str == QLatin1String("B7")) { - return QPrinter::B7; - } else if (str == QLatin1String("B8")) { - return QPrinter::B8; - } else if (str == QLatin1String("B9")) { - return QPrinter::B9; - } else if (str == QLatin1String("C5E")) { - return QPrinter::C5E; - } else if (str == QLatin1String("Comm10E")) { - return QPrinter::Comm10E; - } else if (str == QLatin1String("DLE")) { - return QPrinter::DLE; - } else if (str == QLatin1String("Folio")) { - return QPrinter::Folio; - } else if (str == QLatin1String("Ledger")) { - return QPrinter::Ledger; - } else if (str == QLatin1String("Tabloid")) { - return QPrinter::Tabloid; - } else { - return QPrinter::Custom; - } -} - -QString QPrinterInfoPrivate::pageSize2String(QPrinter::PaperSize size) -{ - switch (size) { - case QPrinter::A4: - return QLatin1String("A4"); - case QPrinter::B5: - return QLatin1String("B5"); - case QPrinter::Letter: - return QLatin1String("Letter"); - case QPrinter::Legal: - return QLatin1String("Legal"); - case QPrinter::Executive: - return QLatin1String("Executive"); - case QPrinter::A0: - return QLatin1String("A0"); - case QPrinter::A1: - return QLatin1String("A1"); - case QPrinter::A2: - return QLatin1String("A2"); - case QPrinter::A3: - return QLatin1String("A3"); - case QPrinter::A5: - return QLatin1String("A5"); - case QPrinter::A6: - return QLatin1String("A6"); - case QPrinter::A7: - return QLatin1String("A7"); - case QPrinter::A8: - return QLatin1String("A8"); - case QPrinter::A9: - return QLatin1String("A9"); - case QPrinter::B0: - return QLatin1String("B0"); - case QPrinter::B1: - return QLatin1String("B1"); - case QPrinter::B10: - return QLatin1String("B10"); - case QPrinter::B2: - return QLatin1String("B2"); - case QPrinter::B3: - return QLatin1String("B3"); - case QPrinter::B4: - return QLatin1String("B4"); - case QPrinter::B6: - return QLatin1String("B6"); - case QPrinter::B7: - return QLatin1String("B7"); - case QPrinter::B8: - return QLatin1String("B8"); - case QPrinter::B9: - return QLatin1String("B9"); - case QPrinter::C5E: - return QLatin1String("C5E"); - case QPrinter::Comm10E: - return QLatin1String("Comm10E"); - case QPrinter::DLE: - return QLatin1String("DLE"); - case QPrinter::Folio: - return QLatin1String("Folio"); - case QPrinter::Ledger: - return QLatin1String("Ledger"); - case QPrinter::Tabloid: - return QLatin1String("Tabloid"); - default: - return QLatin1String("Custom"); - } -} - #endif // QT_NO_PRINTER QT_END_NAMESPACE -- cgit v0.12 From f725c90032b83df62432018af362830e899e71c1 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Wed, 1 Dec 2010 07:48:55 +0300 Subject: minor refactoring of QPrinterInfoPrivate use member initialization lists; remove unused Q_DECLARE_PUBLIC stuff and q_ptr member; make members public instead Merge-request: 2516 Signed-off-by: axis --- src/gui/painting/qprinterinfo_mac.cpp | 42 +++++++---------------------- src/gui/painting/qprinterinfo_unix.cpp | 48 +++++++++------------------------- src/gui/painting/qprinterinfo_win.cpp | 42 +++++++---------------------- 3 files changed, 32 insertions(+), 100 deletions(-) diff --git a/src/gui/painting/qprinterinfo_mac.cpp b/src/gui/painting/qprinterinfo_mac.cpp index 9b199f4..6a48c91 100644 --- a/src/gui/painting/qprinterinfo_mac.cpp +++ b/src/gui/painting/qprinterinfo_mac.cpp @@ -49,18 +49,20 @@ QT_BEGIN_NAMESPACE class QPrinterInfoPrivate { -Q_DECLARE_PUBLIC(QPrinterInfo) public: - ~QPrinterInfoPrivate(); - QPrinterInfoPrivate(); - QPrinterInfoPrivate(const QString& name); - -private: - QPrinterInfo* q_ptr; + QPrinterInfoPrivate() : + m_isNull(true), m_default(false) + {} + QPrinterInfoPrivate(const QString& name) : + m_name(name), + m_isNull(false), m_default(false) + {} + ~QPrinterInfoPrivate() + {} QString m_name; - bool m_default; bool m_isNull; + bool m_default; }; static QPrinterInfoPrivate nullQPrinterInfoPrivate; @@ -139,7 +141,6 @@ QPrinterInfo::QPrinterInfo() QPrinterInfo::QPrinterInfo(const QString& name) : d_ptr(new QPrinterInfoPrivate(name)) { - d_ptr->q_ptr = this; } QPrinterInfo::QPrinterInfo(const QPrinterInfo& src) @@ -152,7 +153,6 @@ QPrinterInfo& QPrinterInfo::operator=(const QPrinterInfo& src) { Q_ASSERT(d_ptr); d_ptr.reset(new QPrinterInfoPrivate(*src.d_ptr)); - d_ptr->q_ptr = this; return *this; } @@ -210,28 +210,6 @@ QList QPrinterInfo::supportedPaperSizes() const return paperList; } -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// - -QPrinterInfoPrivate::QPrinterInfoPrivate() : - q_ptr(NULL), - m_default(false), - m_isNull(true) -{ -} - -QPrinterInfoPrivate::QPrinterInfoPrivate(const QString& name) : - q_ptr(NULL), - m_name(name), - m_default(false), - m_isNull(false) -{ -} - -QPrinterInfoPrivate::~QPrinterInfoPrivate() -{ -} - #endif // QT_NO_PRINTER QT_END_NAMESPACE diff --git a/src/gui/painting/qprinterinfo_unix.cpp b/src/gui/painting/qprinterinfo_unix.cpp index 0d4cc16..eb16a1b 100644 --- a/src/gui/painting/qprinterinfo_unix.cpp +++ b/src/gui/painting/qprinterinfo_unix.cpp @@ -124,21 +124,26 @@ static inline const char *paperSize2String(QPrinter::PaperSize size) class QPrinterInfoPrivate { -Q_DECLARE_PUBLIC(QPrinterInfo) public: - QPrinterInfoPrivate(); - QPrinterInfoPrivate(const QString& name); - ~QPrinterInfoPrivate(); + QPrinterInfoPrivate() : + m_isNull(true), m_default(false), + m_mustGetPaperSizes(true), m_cupsPrinterIndex(0) + {} + QPrinterInfoPrivate(const QString& name) : + m_name(name), + m_isNull(false), m_default(false), + m_mustGetPaperSizes(true), m_cupsPrinterIndex(0) + {} + ~QPrinterInfoPrivate() + {} -private: QString m_name; bool m_isNull; bool m_default; + mutable bool m_mustGetPaperSizes; mutable QList m_paperSizes; int m_cupsPrinterIndex; - - QPrinterInfo* q_ptr; }; static QPrinterInfoPrivate nullQPrinterInfoPrivate; @@ -946,7 +951,6 @@ QPrinterInfo::QPrinterInfo(const QPrinter& printer) { Q_D(QPrinterInfo); - d->q_ptr = this; #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) QCUPSSupport cups; @@ -990,7 +994,6 @@ QPrinterInfo::QPrinterInfo(const QPrinter& printer) QPrinterInfo::QPrinterInfo(const QString& name) : d_ptr(new QPrinterInfoPrivate(name)) { - d_ptr->q_ptr = this; } QPrinterInfo::~QPrinterInfo() @@ -1001,7 +1004,6 @@ QPrinterInfo& QPrinterInfo::operator=(const QPrinterInfo& src) { Q_ASSERT(d_ptr); d_ptr.reset(new QPrinterInfoPrivate(*src.d_ptr)); - d_ptr->q_ptr = this; return *this; } @@ -1046,32 +1048,6 @@ QList< QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const return d->m_paperSizes; } -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// - -QPrinterInfoPrivate::QPrinterInfoPrivate() -{ - m_isNull = true; - m_default = false; - m_mustGetPaperSizes = true; - m_cupsPrinterIndex = 0; - q_ptr = 0; -} - -QPrinterInfoPrivate::QPrinterInfoPrivate(const QString& name) -{ - m_name = name; - m_isNull = false; - m_default = false; - m_mustGetPaperSizes = true; - m_cupsPrinterIndex = 0; - q_ptr = 0; -} - -QPrinterInfoPrivate::~QPrinterInfoPrivate() -{ -} - #endif // QT_NO_PRINTER QT_END_NAMESPACE diff --git a/src/gui/painting/qprinterinfo_win.cpp b/src/gui/painting/qprinterinfo_win.cpp index caada1f..808de2c 100644 --- a/src/gui/painting/qprinterinfo_win.cpp +++ b/src/gui/painting/qprinterinfo_win.cpp @@ -53,18 +53,20 @@ extern QPrinter::PaperSize mapDevmodePaperSize(int s); class QPrinterInfoPrivate { -Q_DECLARE_PUBLIC(QPrinterInfo) public: - ~QPrinterInfoPrivate(); - QPrinterInfoPrivate(); - QPrinterInfoPrivate(const QString& name); + QPrinterInfoPrivate() : + m_isNull(true), m_default(false) + {} + QPrinterInfoPrivate(const QString& name) : + m_name(name), + m_isNull(false), m_default(false) + {} + ~QPrinterInfoPrivate() + {} -private: QString m_name; - bool m_default; bool m_isNull; - - QPrinterInfo* q_ptr; + bool m_default; }; static QPrinterInfoPrivate nullQPrinterInfoPrivate; @@ -142,7 +144,6 @@ QPrinterInfo::QPrinterInfo() QPrinterInfo::QPrinterInfo(const QString& name) : d_ptr(new QPrinterInfoPrivate(name)) { - d_ptr->q_ptr = this; } QPrinterInfo::QPrinterInfo(const QPrinterInfo& src) @@ -173,7 +174,6 @@ QPrinterInfo& QPrinterInfo::operator=(const QPrinterInfo& src) { Q_ASSERT(d_ptr); d_ptr.reset(new QPrinterInfoPrivate(*src.d_ptr)); - d_ptr->q_ptr = this; return *this; } @@ -218,28 +218,6 @@ QList QPrinterInfo::supportedPaperSizes() const return paperList; } -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// - -QPrinterInfoPrivate::QPrinterInfoPrivate() : - m_default(false), - m_isNull(true), - q_ptr(NULL) -{ -} - -QPrinterInfoPrivate::QPrinterInfoPrivate(const QString& name) : - m_name(name), - m_default(false), - m_isNull(false), - q_ptr(NULL) -{ -} - -QPrinterInfoPrivate::~QPrinterInfoPrivate() -{ -} - #endif // QT_NO_PRINTER QT_END_NAMESPACE -- cgit v0.12 From 2cf77579cf41594e036beeacf3dc3b6aa9f05cfa Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Wed, 1 Dec 2010 12:31:19 +0300 Subject: refactoring of QPrinterInfo move QPrinterInfoPrivate to it's own header file; rename qprinterinfo.qdoc to qprinterinfo.cpp to make it consistent with others; squash the duplicated code into qprinterinfo.cpp; avoid extra d_ptr assignments in the QPrinterInfo copying c-tor; simplify the QPrinterInfo from QPrinter c-tor code; fix styling and few method param names; remove the `m_` prefix of QPrinterInfoPrivate's members (as they are members of a private class anyway ;P) remove the boilerplates Merge-request: 2516 Signed-off-by: axis --- src/gui/painting/painting.pri | 2 + src/gui/painting/qprinterinfo.cpp | 173 +++++++++++++++++++++++++++++++++ src/gui/painting/qprinterinfo.h | 15 +-- src/gui/painting/qprinterinfo.qdoc | 125 ------------------------ src/gui/painting/qprinterinfo_mac.cpp | 100 +------------------ src/gui/painting/qprinterinfo_p.h | 108 ++++++++++++++++++++ src/gui/painting/qprinterinfo_unix.cpp | 159 +++--------------------------- src/gui/painting/qprinterinfo_win.cpp | 106 ++------------------ 8 files changed, 317 insertions(+), 471 deletions(-) create mode 100644 src/gui/painting/qprinterinfo.cpp delete mode 100644 src/gui/painting/qprinterinfo.qdoc create mode 100644 src/gui/painting/qprinterinfo_p.h diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index 099619c..51f2538 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -34,6 +34,7 @@ HEADERS += \ painting/qprinter.h \ painting/qprinter_p.h \ painting/qprinterinfo.h \ + painting/qprinterinfo_p.h \ painting/qrasterizer_p.h \ painting/qregion.h \ painting/qstroker_p.h \ @@ -73,6 +74,7 @@ SOURCES += \ painting/qprintengine_pdf.cpp \ painting/qprintengine_ps.cpp \ painting/qprinter.cpp \ + painting/qprinterinfo.cpp \ painting/qrasterizer.cpp \ painting/qregion.cpp \ painting/qstroker.cpp \ diff --git a/src/gui/painting/qprinterinfo.cpp b/src/gui/painting/qprinterinfo.cpp new file mode 100644 index 0000000..21d56f3 --- /dev/null +++ b/src/gui/painting/qprinterinfo.cpp @@ -0,0 +1,173 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of this +** file. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qprinterinfo.h" +#include "qprinterinfo_p.h" + +#ifndef QT_NO_PRINTER + +QT_BEGIN_NAMESPACE + +QPrinterInfoPrivate QPrinterInfoPrivate::shared_null; + + +/*! + \class QPrinterInfo + + \brief The QPrinterInfo class gives access to information about + existing printers. + + \ingroup printing + + Use the static functions to generate a list of QPrinterInfo + objects. Each QPrinterInfo object in the list represents a single + printer and can be queried for name, supported paper sizes, and + whether or not it is the default printer. + + \since 4.4 +*/ + +/*! + \fn QList QPrinterInfo::availablePrinters() + + Returns a list of available printers on the system. +*/ + +/*! + \fn QPrinterInfo QPrinterInfo::defaultPrinter() + + Returns the default printer on the system. + + The return value should be checked using isNull() before being + used, in case there is no default printer. + + \sa isNull() +*/ + +/*! + Constructs an empty QPrinterInfo object. + + \sa isNull() +*/ +QPrinterInfo::QPrinterInfo() + : d_ptr(&QPrinterInfoPrivate::shared_null) +{ +} + +/*! + Constructs a copy of \a other. +*/ +QPrinterInfo::QPrinterInfo(const QPrinterInfo &other) + : d_ptr(new QPrinterInfoPrivate(*other.d_ptr)) +{ +} + +/*! + Constructs a QPrinterInfo object from \a printer. +*/ +QPrinterInfo::QPrinterInfo(const QPrinter &printer) + : d_ptr(&QPrinterInfoPrivate::shared_null) +{ + foreach (const QPrinterInfo &printerInfo, availablePrinters()) { + if (printerInfo.printerName() == printer.printerName()) { + d_ptr.reset(new QPrinterInfoPrivate(*printerInfo.d_ptr)); + break; + } + } +} + +/*! + \internal +*/ +QPrinterInfo::QPrinterInfo(const QString &name) + : d_ptr(new QPrinterInfoPrivate(name)) +{ +} + +/*! + Destroys the QPrinterInfo object. References to the values in the + object become invalid. +*/ +QPrinterInfo::~QPrinterInfo() +{ +} + +/*! + Sets the QPrinterInfo object to be equal to \a other. +*/ +QPrinterInfo &QPrinterInfo::operator=(const QPrinterInfo &other) +{ + Q_ASSERT(d_ptr); + d_ptr.reset(new QPrinterInfoPrivate(*other.d_ptr)); + return *this; +} + +/*! + Returns the name of the printer. + + \sa QPrinter::setPrinterName() +*/ +QString QPrinterInfo::printerName() const +{ + const Q_D(QPrinterInfo); + return d->name; +} + +/*! + Returns whether this QPrinterInfo object holds a printer definition. + + An empty QPrinterInfo object could result for example from calling + defaultPrinter() when there are no printers on the system. +*/ +bool QPrinterInfo::isNull() const +{ + const Q_D(QPrinterInfo); + return d->isNull; +} + +/*! + Returns whether this printer is the default printer. +*/ +bool QPrinterInfo::isDefault() const +{ + const Q_D(QPrinterInfo); + return d->isDefault; +} + +/*! + \fn QList< QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const + \since 4.4 + + Returns a list of supported paper sizes by the printer. + + Not all printer drivers support this query, so the list may be empty. + On Mac OS X 10.3, this function always returns an empty list. +*/ + +QT_END_NAMESPACE + +#endif // QT_NO_PRINTER diff --git a/src/gui/painting/qprinterinfo.h b/src/gui/painting/qprinterinfo.h index 063c6b9..c8c9534 100644 --- a/src/gui/painting/qprinterinfo.h +++ b/src/gui/painting/qprinterinfo.h @@ -42,9 +42,10 @@ #ifndef QPRINTERINFO_H #define QPRINTERINFO_H -#include #include +#include + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -56,15 +57,13 @@ class QPrinterInfoPrivate; class QPrinterInfoPrivateDeleter; class Q_GUI_EXPORT QPrinterInfo { -Q_DECLARE_PRIVATE(QPrinterInfo) - public: QPrinterInfo(); - QPrinterInfo(const QPrinterInfo& src); - QPrinterInfo(const QPrinter& printer); + QPrinterInfo(const QPrinterInfo &other); + QPrinterInfo(const QPrinter &printer); ~QPrinterInfo(); - QPrinterInfo& operator=(const QPrinterInfo& src); + QPrinterInfo &operator=(const QPrinterInfo &other); QString printerName() const; bool isNull() const; @@ -75,8 +74,10 @@ public: static QPrinterInfo defaultPrinter(); private: - QPrinterInfo(const QString& name); + QPrinterInfo(const QString &name); +private: + Q_DECLARE_PRIVATE(QPrinterInfo) QScopedPointer d_ptr; }; diff --git a/src/gui/painting/qprinterinfo.qdoc b/src/gui/painting/qprinterinfo.qdoc deleted file mode 100644 index 9193213..0000000 --- a/src/gui/painting/qprinterinfo.qdoc +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of this -** file. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class QPrinterInfo - - \brief The QPrinterInfo class gives access to information about - existing printers. - - \ingroup printing - - Use the static functions to generate a list of QPrinterInfo - objects. Each QPrinterInfo object in the list represents a single - printer and can be queried for name, supported paper sizes, and - whether or not it is the default printer. - - \since 4.4 -*/ - -/*! - \fn QList QPrinterInfo::availablePrinters() - - Returns a list of available printers on the system. -*/ - -/*! - \fn QPrinterInfo QPrinterInfo::defaultPrinter() - - Returns the default printer on the system. - - The return value should be checked using isNull() before being - used, in case there is no default printer. - - \sa isNull() -*/ - -/*! - \fn QPrinterInfo::QPrinterInfo() - - Constructs an empty QPrinterInfo object. - - \sa isNull() -*/ - -/*! - \fn QPrinterInfo::QPrinterInfo(const QPrinterInfo& src) - - Constructs a copy of \a src. -*/ - -/*! - \fn QPrinterInfo::QPrinterInfo(const QPrinter& printer) - - Constructs a QPrinterInfo object from \a printer. -*/ - -/*! - \fn QPrinterInfo::~QPrinterInfo() - - Destroys the QPrinterInfo object. References to the values in the - object become invalid. -*/ - -/*! - \fn QPrinterInfo& QPrinterInfo::operator=(const QPrinterInfo& src) - - Sets the QPrinterInfo object to be equal to \a src. -*/ - -/*! - \fn QString QPrinterInfo::printerName() const - - Returns the name of the printer. - - \sa QPrinter::setPrinterName() -*/ - -/*! - \fn bool QPrinterInfo::isNull() const - - Returns whether this QPrinterInfo object holds a printer definition. - - An empty QPrinterInfo object could result for example from calling - defaultPrinter() when there are no printers on the system. -*/ - -/*! - \fn bool QPrinterInfo::isDefault() const - - Returns whether this printer is the default printer. -*/ - -/*! - \fn QList< QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const - \since 4.4 - - Returns a list of supported paper sizes by the printer. - - Not all printer drivers support this query, so the list may be empty. - On Mac OS X 10.3, this function always returns an empty list. -*/ diff --git a/src/gui/painting/qprinterinfo_mac.cpp b/src/gui/painting/qprinterinfo_mac.cpp index 6a48c91..9d0e886 100644 --- a/src/gui/painting/qprinterinfo_mac.cpp +++ b/src/gui/painting/qprinterinfo_mac.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qprinterinfo.h" +#include "qprinterinfo_p.h" #include "private/qt_mac_p.h" @@ -47,40 +48,7 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_PRINTER -class QPrinterInfoPrivate -{ -public: - QPrinterInfoPrivate() : - m_isNull(true), m_default(false) - {} - QPrinterInfoPrivate(const QString& name) : - m_name(name), - m_isNull(false), m_default(false) - {} - ~QPrinterInfoPrivate() - {} - - QString m_name; - bool m_isNull; - bool m_default; -}; - -static QPrinterInfoPrivate nullQPrinterInfoPrivate; - -class QPrinterInfoPrivateDeleter -{ -public: - static inline void cleanup(QPrinterInfoPrivate *d) - { - if (d != &nullQPrinterInfoPrivate) - delete d; - } -}; - -extern QPrinter::PaperSize qSizeFTopaperSize(const QSizeF& size); - -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// +extern QPrinter::PaperSize qSizeFTopaperSize(const QSizeF &size); QList QPrinterInfo::availablePrinters() { @@ -96,7 +64,7 @@ QList QPrinterInfo::availablePrinters() QString name = QCFString::toQString(PMPrinterGetName(printer)); printers.append(QPrinterInfo(name)); if (PMPrinterIsDefault(printer)) { - printers[i].d_ptr->m_default = true; + printers[i].d_ptr->isDefault = true; } } } @@ -114,71 +82,11 @@ QPrinterInfo QPrinterInfo::defaultPrinter(){ return QPrinterInfo(); } -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// - -QPrinterInfo::QPrinterInfo(const QPrinter& prn) - : d_ptr(&nullQPrinterInfoPrivate) -{ - QList list = availablePrinters(); - for (int c = 0; c < list.size(); ++c) { - if (prn.printerName() == list[c].printerName()) { - *this = list[c]; - return; - } - } -} - -QPrinterInfo::~QPrinterInfo() -{ -} - -QPrinterInfo::QPrinterInfo() - : d_ptr(&nullQPrinterInfoPrivate) -{ -} - -QPrinterInfo::QPrinterInfo(const QString& name) - : d_ptr(new QPrinterInfoPrivate(name)) -{ -} - -QPrinterInfo::QPrinterInfo(const QPrinterInfo& src) - : d_ptr(&nullQPrinterInfoPrivate) -{ - *this = src; -} - -QPrinterInfo& QPrinterInfo::operator=(const QPrinterInfo& src) -{ - Q_ASSERT(d_ptr); - d_ptr.reset(new QPrinterInfoPrivate(*src.d_ptr)); - return *this; -} - -QString QPrinterInfo::printerName() const -{ - const Q_D(QPrinterInfo); - return d->m_name; -} - -bool QPrinterInfo::isNull() const -{ - const Q_D(QPrinterInfo); - return d->m_isNull; -} - -bool QPrinterInfo::isDefault() const -{ - const Q_D(QPrinterInfo); - return d->m_default; -} - QList QPrinterInfo::supportedPaperSizes() const { const Q_D(QPrinterInfo); - PMPrinter cfPrn = PMPrinterCreateFromPrinterID(QCFString::toCFStringRef(d->m_name)); + PMPrinter cfPrn = PMPrinterCreateFromPrinterID(QCFString::toCFStringRef(d->name)); if (!cfPrn) return QList(); diff --git a/src/gui/painting/qprinterinfo_p.h b/src/gui/painting/qprinterinfo_p.h new file mode 100644 index 0000000..f5981d4 --- /dev/null +++ b/src/gui/painting/qprinterinfo_p.h @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QPRINTERINFO_P_H +#define QPRINTERINFO_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "QtCore/qglobal.h" + +#ifndef QT_NO_PRINTER + +#include "QtCore/qlist.h" + +QT_BEGIN_NAMESPACE + +class QPrinterInfoPrivate +{ +public: + QPrinterInfoPrivate(const QString& name = QString()) : + name(name), isNull(false), isDefault(false) +#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_SYMBIAN)) || defined(Q_WS_QPA) +#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) + , cupsPrinterIndex(0), hasPaperSizes(false) +#endif +#endif + {} + ~QPrinterInfoPrivate() + {} + + static QPrinterInfoPrivate shared_null; + + QString name; + bool isNull; + bool isDefault; + +#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_SYMBIAN)) || defined(Q_WS_QPA) +#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) + int cupsPrinterIndex; + mutable bool hasPaperSizes; + mutable QList paperSizes; +#endif +#endif +}; + + +class QPrinterInfoPrivateDeleter +{ +public: + static inline void cleanup(QPrinterInfoPrivate *d) + { + if (d != &QPrinterInfoPrivate::shared_null) + delete d; + } +}; + +QT_END_NAMESPACE + +#endif // QT_NO_PRINTER + +#endif // QPRINTERINFO_P_H diff --git a/src/gui/painting/qprinterinfo_unix.cpp b/src/gui/painting/qprinterinfo_unix.cpp index eb16a1b..c30fcb4 100644 --- a/src/gui/painting/qprinterinfo_unix.cpp +++ b/src/gui/painting/qprinterinfo_unix.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qprinterinfo.h" +#include "qprinterinfo_p.h" #include #include @@ -121,46 +122,6 @@ static inline const char *paperSize2String(QPrinter::PaperSize size) } #endif - -class QPrinterInfoPrivate -{ -public: - QPrinterInfoPrivate() : - m_isNull(true), m_default(false), - m_mustGetPaperSizes(true), m_cupsPrinterIndex(0) - {} - QPrinterInfoPrivate(const QString& name) : - m_name(name), - m_isNull(false), m_default(false), - m_mustGetPaperSizes(true), m_cupsPrinterIndex(0) - {} - ~QPrinterInfoPrivate() - {} - - QString m_name; - bool m_isNull; - bool m_default; - - mutable bool m_mustGetPaperSizes; - mutable QList m_paperSizes; - int m_cupsPrinterIndex; -}; - -static QPrinterInfoPrivate nullQPrinterInfoPrivate; - -class QPrinterInfoPrivateDeleter -{ -public: - static inline void cleanup(QPrinterInfoPrivate *d) - { - if (d != &nullQPrinterInfoPrivate) - delete d; - } -}; - -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// - void qt_perhapsAddPrinter(QList *printers, const QString &name, QString host, QString comment, QStringList aliases) @@ -891,9 +852,8 @@ QList QPrinterInfo::availablePrinters() QList list; #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) - QCUPSSupport cups; if (QCUPSSupport::isAvailable()) { - //const ppd_file_t* cupsPPD = cups.currentPPD(); + QCUPSSupport cups; int cupsPrinterCount = cups.availablePrintersCount(); const cups_dest_t* cupsPrinters = cups.availablePrinters(); @@ -903,8 +863,8 @@ QList QPrinterInfo::availablePrinters() printerName += QLatin1Char('/') + QString::fromLocal8Bit(cupsPrinters[i].instance); list.append(QPrinterInfo(printerName)); if (cupsPrinters[i].is_default) - list[i].d_ptr->m_default = true; - list[i].d_ptr->m_cupsPrinterIndex = i; + list[i].d_ptr->isDefault = true; + list[i].d_ptr->cupsPrinterIndex = i; } } else { #endif @@ -916,7 +876,7 @@ QList QPrinterInfo::availablePrinters() list.append(QPrinterInfo((*i).name)); } if (defprn >= 0 && defprn < lprPrinters.size()) { - list[defprn].d_ptr->m_default = true; + list[defprn].d_ptr->isDefault = true; } #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) } @@ -935,117 +895,30 @@ QPrinterInfo QPrinterInfo::defaultPrinter() return (prnList.size() > 0) ? prnList[0] : QPrinterInfo(); } -QPrinterInfo::QPrinterInfo() - : d_ptr(&nullQPrinterInfoPrivate) +QList QPrinterInfo::supportedPaperSizes() const { -} - -QPrinterInfo::QPrinterInfo(const QPrinterInfo& src) - : d_ptr(&nullQPrinterInfoPrivate) -{ - *this = src; -} - -QPrinterInfo::QPrinterInfo(const QPrinter& printer) - : d_ptr(new QPrinterInfoPrivate(printer.printerName())) -{ - - Q_D(QPrinterInfo); - -#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) - QCUPSSupport cups; - if (QCUPSSupport::isAvailable()) { - int cupsPrinterCount = cups.availablePrintersCount(); - const cups_dest_t* cupsPrinters = cups.availablePrinters(); - - for (int i = 0; i < cupsPrinterCount; ++i) { - QString printerName(QString::fromLocal8Bit(cupsPrinters[i].name)); - if (cupsPrinters[i].instance) - printerName += QLatin1Char('/') + QString::fromLocal8Bit(cupsPrinters[i].instance); - if (printerName == printer.printerName()) { - if (cupsPrinters[i].is_default) - d->m_default = true; - d->m_cupsPrinterIndex = i; - return; - } - } - } else { -#endif - QList lprPrinters; - int defprn = qt_getLprPrinters(lprPrinters); - // populating printer combo - QList::const_iterator i = lprPrinters.constBegin(); - int c; - for(c = 0; i != lprPrinters.constEnd(); ++i, ++c) { - if (i->name == printer.printerName()) { - if (defprn == c) - d->m_default = true; - return; - } - } #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) - } -#endif - - // Printer not found. - d_ptr.reset(&nullQPrinterInfoPrivate); -} - -QPrinterInfo::QPrinterInfo(const QString& name) - : d_ptr(new QPrinterInfoPrivate(name)) -{ -} - -QPrinterInfo::~QPrinterInfo() -{ -} - -QPrinterInfo& QPrinterInfo::operator=(const QPrinterInfo& src) -{ - Q_ASSERT(d_ptr); - d_ptr.reset(new QPrinterInfoPrivate(*src.d_ptr)); - return *this; -} - -QString QPrinterInfo::printerName() const -{ const Q_D(QPrinterInfo); - return d->m_name; -} - -bool QPrinterInfo::isNull() const -{ - const Q_D(QPrinterInfo); - return d->m_isNull; -} - -bool QPrinterInfo::isDefault() const -{ - const Q_D(QPrinterInfo); - return d->m_default; -} -QList< QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const -{ - const Q_D(QPrinterInfo); - if (d->m_mustGetPaperSizes) { - d->m_mustGetPaperSizes = false; + if (!d->hasPaperSizes) { + d->hasPaperSizes = true; -#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) - QCUPSSupport cups; if (QCUPSSupport::isAvailable()) { // Find paper sizes from CUPS. - cups.setCurrentPrinter(d->m_cupsPrinterIndex); + QCUPSSupport cups; + cups.setCurrentPrinter(d->cupsPrinterIndex); const ppd_option_t* sizes = cups.pageSizes(); if (sizes) { for (int j = 0; j < sizes->num_choices; ++j) - d->m_paperSizes.append(string2PaperSize(sizes->choices[j].choice)); + d->paperSizes.append(string2PaperSize(sizes->choices[j].choice)); } } -#endif - } - return d->m_paperSizes; + + return d->paperSizes; +#else + return QList(); +#endif } #endif // QT_NO_PRINTER diff --git a/src/gui/painting/qprinterinfo_win.cpp b/src/gui/painting/qprinterinfo_win.cpp index 808de2c..962aa2d 100644 --- a/src/gui/painting/qprinterinfo_win.cpp +++ b/src/gui/painting/qprinterinfo_win.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qprinterinfo.h" +#include "qprinterinfo_p.h" #include @@ -51,39 +52,6 @@ QT_BEGIN_NAMESPACE extern QPrinter::PaperSize mapDevmodePaperSize(int s); -class QPrinterInfoPrivate -{ -public: - QPrinterInfoPrivate() : - m_isNull(true), m_default(false) - {} - QPrinterInfoPrivate(const QString& name) : - m_name(name), - m_isNull(false), m_default(false) - {} - ~QPrinterInfoPrivate() - {} - - QString m_name; - bool m_isNull; - bool m_default; -}; - -static QPrinterInfoPrivate nullQPrinterInfoPrivate; - -class QPrinterInfoPrivateDeleter -{ -public: - static inline void cleanup(QPrinterInfoPrivate *d) - { - if (d != &nullQPrinterInfoPrivate) - delete d; - } -}; - -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// - QList QPrinterInfo::availablePrinters() { QList printers; @@ -105,7 +73,7 @@ QList QPrinterInfo::availablePrinters() for (uint i = 0; i < returned; ++i) { printers.append(QPrinterInfo(QString::fromWCharArray(infoList[i].pPrinterName))); if (printers.at(i).printerName() == defPrn.printerName()) - printers[i].d_ptr->m_default = true; + printers[i].d_ptr->isDefault = true; } delete [] buffer; } @@ -127,86 +95,24 @@ QPrinterInfo QPrinterInfo::defaultPrinter() QString printerName = noConfiguredPrinters ? QString() : info.at(0); QPrinterInfo prn(printerName); - prn.d_ptr->m_default = true; + prn.d_ptr->isDefault = true; if (noConfiguredPrinters) - prn.d_ptr->m_isNull = true; + prn.d_ptr->isNull = true; return prn; } -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// - -QPrinterInfo::QPrinterInfo() - : d_ptr(&nullQPrinterInfoPrivate) -{ -} - -QPrinterInfo::QPrinterInfo(const QString& name) - : d_ptr(new QPrinterInfoPrivate(name)) -{ -} - -QPrinterInfo::QPrinterInfo(const QPrinterInfo& src) - : d_ptr(&nullQPrinterInfoPrivate) -{ - *this = src; -} - -QPrinterInfo::QPrinterInfo(const QPrinter& prn) - : d_ptr(&nullQPrinterInfoPrivate) -{ - QList list = availablePrinters(); - for (int c = 0; c < list.size(); ++c) { - if (prn.printerName() == list[c].printerName()) { - *this = list[c]; - return; - } - } - - *this = QPrinterInfo(); -} - -QPrinterInfo::~QPrinterInfo() -{ -} - -QPrinterInfo& QPrinterInfo::operator=(const QPrinterInfo& src) -{ - Q_ASSERT(d_ptr); - d_ptr.reset(new QPrinterInfoPrivate(*src.d_ptr)); - return *this; -} - -QString QPrinterInfo::printerName() const -{ - const Q_D(QPrinterInfo); - return d->m_name; -} - -bool QPrinterInfo::isNull() const -{ - const Q_D(QPrinterInfo); - return d->m_isNull; -} - -bool QPrinterInfo::isDefault() const -{ - const Q_D(QPrinterInfo); - return d->m_default; -} - QList QPrinterInfo::supportedPaperSizes() const { const Q_D(QPrinterInfo); QList paperList; - DWORD size = DeviceCapabilities(reinterpret_cast(d->m_name.utf16()), + DWORD size = DeviceCapabilities(reinterpret_cast(d->name.utf16()), NULL, DC_PAPERS, NULL, NULL); if ((int)size == -1) return paperList; wchar_t *papers = new wchar_t[size]; - size = DeviceCapabilities(reinterpret_cast(d->m_name.utf16()), + size = DeviceCapabilities(reinterpret_cast(d->name.utf16()), NULL, DC_PAPERS, papers, NULL); for (int c = 0; c < (int)size; ++c) { -- cgit v0.12 From 70fd5a220d966279eb66df08ad69539bb26d59cd Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Wed, 1 Dec 2010 12:54:52 +0300 Subject: micro-optimizations, clean-ups and styling fixes Merge-request: 2516 Signed-off-by: axis --- src/gui/painting/qprinterinfo_mac.cpp | 67 ++++++++++++++++----------------- src/gui/painting/qprinterinfo_unix.cpp | 46 +++++++++++------------ src/gui/painting/qprinterinfo_win.cpp | 68 +++++++++++++++------------------- 3 files changed, 83 insertions(+), 98 deletions(-) diff --git a/src/gui/painting/qprinterinfo_mac.cpp b/src/gui/painting/qprinterinfo_mac.cpp index 9d0e886..8d41217 100644 --- a/src/gui/painting/qprinterinfo_mac.cpp +++ b/src/gui/painting/qprinterinfo_mac.cpp @@ -54,68 +54,63 @@ QList QPrinterInfo::availablePrinters() { QList printers; - OSStatus status = noErr; - QCFType printerList; - status = PMServerCreatePrinterList(kPMServerLocal, &printerList); - if (status == noErr) { - CFIndex count = CFArrayGetCount(printerList); - for (CFIndex i=0; i(const_cast(CFArrayGetValueAtIndex(printerList, i))); - QString name = QCFString::toQString(PMPrinterGetName(printer)); - printers.append(QPrinterInfo(name)); - if (PMPrinterIsDefault(printer)) { - printers[i].d_ptr->isDefault = true; - } + QCFType array; + if (PMServerCreatePrinterList(kPMServerLocal, &array) == noErr) { + CFIndex count = CFArrayGetCount(array); + for (int i = 0; i < count; ++i) { + PMPrinter printer = static_cast(const_cast(CFArrayGetValueAtIndex(array, i))); + QString printerName = QCFString::toQString(PMPrinterGetName(printer)); + + QPrinterInfo printerInfo(printerName); + if (PMPrinterIsDefault(printer)) + printerInfo.d_ptr->isDefault = true; + printers.append(printerInfo); } } return printers; } -QPrinterInfo QPrinterInfo::defaultPrinter(){ +QPrinterInfo QPrinterInfo::defaultPrinter() +{ QList printers = availablePrinters(); - for (int c = 0; c < printers.size(); ++c) { - if (printers[c].isDefault()) { - return printers[c]; - } + foreach (const QPrinterInfo &printerInfo, printers) { + if (printerInfo.isDefault()) + return printerInfo; } - return QPrinterInfo(); + + return printers.value(0); } QList QPrinterInfo::supportedPaperSizes() const { const Q_D(QPrinterInfo); - PMPrinter cfPrn = PMPrinterCreateFromPrinterID(QCFString::toCFStringRef(d->name)); + QList paperSizes; - if (!cfPrn) return QList(); + PMPrinter cfPrn = PMPrinterCreateFromPrinterID(QCFString::toCFStringRef(d->name)); + if (!cfPrn) + return paperSizes; CFArrayRef array; - OSStatus status = PMPrinterGetPaperList(cfPrn, &array); - - if (status != 0) { + if (PMPrinterGetPaperList(cfPrn, &array) != noErr) { PMRelease(cfPrn); - return QList(); + return paperSizes; } - QList paperList; int count = CFArrayGetCount(array); - for (int c = 0; c < count; c++) { - PMPaper paper = static_cast( - const_cast( - CFArrayGetValueAtIndex(array, c))); + for (int i = 0; i < count; ++i) { + PMPaper paper = static_cast(const_cast(CFArrayGetValueAtIndex(array, i))); double width, height; - status = PMPaperGetWidth(paper, &width); - status |= PMPaperGetHeight(paper, &height); - if (status != 0) continue; - - QSizeF size(width * 0.3527, height * 0.3527); - paperList.append(qSizeFTopaperSize(size)); + if (PMPaperGetWidth(paper, &width) == noErr && PMPaperGetHeight(paper, &height) == noErr) { + QSizeF size(width * 0.3527, height * 0.3527); + paperSizes.append(qSizeFTopaperSize(size)); + } } PMRelease(cfPrn); - return paperList; + return paperSizes; } #endif // QT_NO_PRINTER diff --git a/src/gui/painting/qprinterinfo_unix.cpp b/src/gui/painting/qprinterinfo_unix.cpp index c30fcb4..be24bd7 100644 --- a/src/gui/painting/qprinterinfo_unix.cpp +++ b/src/gui/painting/qprinterinfo_unix.cpp @@ -809,12 +809,12 @@ int qt_getLprPrinters(QList& printers) #endif } + QRegExp ps(QLatin1String("[^a-z]ps(?:[^a-z]|$)")); + QRegExp lp(QLatin1String("[^a-z]lp(?:[^a-z]|$)")); + int quality = 0; int best = 0; for (int i = 0; i < printers.size(); ++i) { - QRegExp ps(QLatin1String("[^a-z]ps(?:[^a-z]|$)")); - QRegExp lp(QLatin1String("[^a-z]lp(?:[^a-z]|$)")); - QString name = printers.at(i).name; QString comment = printers.at(i).comment; if (quality < 5 && name == dollarPrinter) { @@ -849,50 +849,48 @@ int qt_getLprPrinters(QList& printers) QList QPrinterInfo::availablePrinters() { - QList list; + QList printers; #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) if (QCUPSSupport::isAvailable()) { QCUPSSupport cups; int cupsPrinterCount = cups.availablePrintersCount(); const cups_dest_t* cupsPrinters = cups.availablePrinters(); - for (int i = 0; i < cupsPrinterCount; ++i) { QString printerName(QString::fromLocal8Bit(cupsPrinters[i].name)); if (cupsPrinters[i].instance) printerName += QLatin1Char('/') + QString::fromLocal8Bit(cupsPrinters[i].instance); - list.append(QPrinterInfo(printerName)); + + QPrinterInfo printerInfo(printerName); if (cupsPrinters[i].is_default) - list[i].d_ptr->isDefault = true; - list[i].d_ptr->cupsPrinterIndex = i; + printerInfo.d_ptr->isDefault = true; + printerInfo.d_ptr->cupsPrinterIndex = i; + printers.append(printerInfo); } - } else { + } else #endif + { QList lprPrinters; int defprn = qt_getLprPrinters(lprPrinters); // populating printer combo - QList::const_iterator i = lprPrinters.constBegin(); - for(; i != lprPrinters.constEnd(); ++i) { - list.append(QPrinterInfo((*i).name)); - } - if (defprn >= 0 && defprn < lprPrinters.size()) { - list[defprn].d_ptr->isDefault = true; - } -#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) + foreach (const QPrinterDescription &description, lprPrinters) + printers.append(QPrinterInfo(description.name)); + if (defprn >= 0 && defprn < printers.size()) + printers[defprn].d_ptr->isDefault = true; } -#endif - return list; + return printers; } QPrinterInfo QPrinterInfo::defaultPrinter() { - QList prnList = availablePrinters(); - for (int i = 0; i < prnList.size(); ++i) { - if (prnList[i].isDefault()) - return prnList[i]; + QList printers = availablePrinters(); + foreach (const QPrinterInfo &printerInfo, printers) { + if (printerInfo.isDefault()) + return printerInfo; } - return (prnList.size() > 0) ? prnList[0] : QPrinterInfo(); + + return printers.value(0); } QList QPrinterInfo::supportedPaperSizes() const diff --git a/src/gui/painting/qprinterinfo_win.cpp b/src/gui/painting/qprinterinfo_win.cpp index 962aa2d..6adf5a4 100644 --- a/src/gui/painting/qprinterinfo_win.cpp +++ b/src/gui/painting/qprinterinfo_win.cpp @@ -55,25 +55,22 @@ extern QPrinter::PaperSize mapDevmodePaperSize(int s); QList QPrinterInfo::availablePrinters() { QList printers; - LPBYTE buffer; + DWORD needed = 0; DWORD returned = 0; - - if ( !EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, NULL, 4, 0, 0, &needed, &returned)) - { - buffer = new BYTE[needed]; - if (!EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS , NULL, - 4, buffer, needed, &needed, &returned)) - { - delete [] buffer; - return printers; - } - PPRINTER_INFO_4 infoList = reinterpret_cast(buffer); - QPrinterInfo defPrn = defaultPrinter(); - for (uint i = 0; i < returned; ++i) { - printers.append(QPrinterInfo(QString::fromWCharArray(infoList[i].pPrinterName))); - if (printers.at(i).printerName() == defPrn.printerName()) - printers[i].d_ptr->isDefault = true; + if (!EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, NULL, 4, 0, 0, &needed, &returned)) { + LPBYTE buffer = new BYTE[needed]; + if (EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, NULL, 4, buffer, needed, &needed, &returned)) { + PPRINTER_INFO_4 infoList = reinterpret_cast(buffer); + QPrinterInfo defPrn = defaultPrinter(); + for (uint i = 0; i < returned; ++i) { + QString printerName(QString::fromWCharArray(infoList[i].pPrinterName)); + + QPrinterInfo printerInfo(printerName); + if (printerInfo.printerName() == defPrn.printerName()) + printerInfo.d_ptr->isDefault = true; + printers.append(printerInfo); + } } delete [] buffer; } @@ -88,40 +85,35 @@ QPrinterInfo QPrinterInfo::defaultPrinter() GetProfileString(L"windows", L"device", (wchar_t*)noPrinters.utf16(), buffer, 256); QString output = QString::fromWCharArray(buffer); - // Filter out the name of the printer, which should be everything - // before a comma. + // Filter out the name of the printer, which should be everything before a comma. bool noConfiguredPrinters = (output == noPrinters); - QStringList info = output.split(QLatin1Char(',')); - QString printerName = noConfiguredPrinters ? QString() : info.at(0); + QString printerName = output.split(QLatin1Char(',')).value(0); - QPrinterInfo prn(printerName); - prn.d_ptr->isDefault = true; + QPrinterInfo printerInfo(printerName); + printerInfo.d_ptr->isDefault = true; if (noConfiguredPrinters) - prn.d_ptr->isNull = true; - return prn; + printerInfo.d_ptr->isNull = true; + return printerInfo; } QList QPrinterInfo::supportedPaperSizes() const { const Q_D(QPrinterInfo); - QList paperList; + + QList paperSizes; DWORD size = DeviceCapabilities(reinterpret_cast(d->name.utf16()), NULL, DC_PAPERS, NULL, NULL); - if ((int)size == -1) - return paperList; - - wchar_t *papers = new wchar_t[size]; - size = DeviceCapabilities(reinterpret_cast(d->name.utf16()), - NULL, DC_PAPERS, papers, NULL); - - for (int c = 0; c < (int)size; ++c) { - paperList.append(mapDevmodePaperSize(papers[c])); + if ((int)size != -1) { + wchar_t *papers = new wchar_t[size]; + size = DeviceCapabilities(reinterpret_cast(d->name.utf16()), + NULL, DC_PAPERS, papers, NULL); + for (int c = 0; c < (int)size; ++c) + paperSizes.append(mapDevmodePaperSize(papers[c])); + delete [] papers; } - delete [] papers; - - return paperList; + return paperSizes; } #endif // QT_NO_PRINTER -- cgit v0.12 From ed2abc6f5d8b2fe9e819d473768767c11f9c83ba Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Wed, 1 Dec 2010 13:24:44 +0300 Subject: fix QPrinterInfo::defaultPrinter() on win to not return a partially filled invalid printer info. is the default printer couldn't be retrieved, return an invalid QPrinterInfo() rather than a semi-invalid info which has isDefault() == true and printerName() == "qt_no_printers" Merge-request: 2516 Signed-off-by: axis --- src/gui/painting/qprinterinfo_win.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/gui/painting/qprinterinfo_win.cpp b/src/gui/painting/qprinterinfo_win.cpp index 6adf5a4..f7b6874 100644 --- a/src/gui/painting/qprinterinfo_win.cpp +++ b/src/gui/painting/qprinterinfo_win.cpp @@ -84,16 +84,15 @@ QPrinterInfo QPrinterInfo::defaultPrinter() wchar_t buffer[256]; GetProfileString(L"windows", L"device", (wchar_t*)noPrinters.utf16(), buffer, 256); QString output = QString::fromWCharArray(buffer); + if (output != noPrinters) { + // Filter out the name of the printer, which should be everything before a comma. + QString printerName = output.split(QLatin1Char(',')).value(0); + QPrinterInfo printerInfo(printerName); + printerInfo.d_ptr->isDefault = true; + return printerInfo; + } - // Filter out the name of the printer, which should be everything before a comma. - bool noConfiguredPrinters = (output == noPrinters); - QString printerName = output.split(QLatin1Char(',')).value(0); - - QPrinterInfo printerInfo(printerName); - printerInfo.d_ptr->isDefault = true; - if (noConfiguredPrinters) - printerInfo.d_ptr->isNull = true; - return printerInfo; + return QPrinterInfo(); } QList QPrinterInfo::supportedPaperSizes() const -- cgit v0.12 From 50af3716c956be0f50fdd896925da7af91d5da2c Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Wed, 1 Dec 2010 13:46:24 +0300 Subject: QPrinterInfo::supportedPaperSizes(): return early if the info is invalid e.g. don't report supported paper sized in any case Merge-request: 2516 Signed-off-by: axis --- src/gui/painting/qprinterinfo_mac.cpp | 2 ++ src/gui/painting/qprinterinfo_unix.cpp | 3 +++ src/gui/painting/qprinterinfo_win.cpp | 2 ++ 3 files changed, 7 insertions(+) diff --git a/src/gui/painting/qprinterinfo_mac.cpp b/src/gui/painting/qprinterinfo_mac.cpp index 8d41217..033682a 100644 --- a/src/gui/painting/qprinterinfo_mac.cpp +++ b/src/gui/painting/qprinterinfo_mac.cpp @@ -87,6 +87,8 @@ QList QPrinterInfo::supportedPaperSizes() const const Q_D(QPrinterInfo); QList paperSizes; + if (isNull()) + return paperSizes; PMPrinter cfPrn = PMPrinterCreateFromPrinterID(QCFString::toCFStringRef(d->name)); if (!cfPrn) diff --git a/src/gui/painting/qprinterinfo_unix.cpp b/src/gui/painting/qprinterinfo_unix.cpp index be24bd7..af2e52a 100644 --- a/src/gui/painting/qprinterinfo_unix.cpp +++ b/src/gui/painting/qprinterinfo_unix.cpp @@ -898,6 +898,9 @@ QList QPrinterInfo::supportedPaperSizes() const #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) const Q_D(QPrinterInfo); + if (isNull()) + return d->paperSizes; + if (!d->hasPaperSizes) { d->hasPaperSizes = true; diff --git a/src/gui/painting/qprinterinfo_win.cpp b/src/gui/painting/qprinterinfo_win.cpp index f7b6874..2d25063 100644 --- a/src/gui/painting/qprinterinfo_win.cpp +++ b/src/gui/painting/qprinterinfo_win.cpp @@ -100,6 +100,8 @@ QList QPrinterInfo::supportedPaperSizes() const const Q_D(QPrinterInfo); QList paperSizes; + if (isNull()) + return paperSizes; DWORD size = DeviceCapabilities(reinterpret_cast(d->name.utf16()), NULL, DC_PAPERS, NULL, NULL); -- cgit v0.12 From 1d6266e751d6b23a15f56bc21c503fe1a71da975 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Wed, 1 Dec 2010 14:28:32 +0300 Subject: get rid of QPrinterInfoPrivate::isNull member invalid QPrinterInfo always have d_ptr == &QPrinterInfoPrivate::shared_null; no need in separate flag for that Merge-request: 2516 Signed-off-by: axis --- src/gui/painting/qprinterinfo.cpp | 2 +- src/gui/painting/qprinterinfo_p.h | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gui/painting/qprinterinfo.cpp b/src/gui/painting/qprinterinfo.cpp index 21d56f3..72f8be3 100644 --- a/src/gui/painting/qprinterinfo.cpp +++ b/src/gui/painting/qprinterinfo.cpp @@ -146,7 +146,7 @@ QString QPrinterInfo::printerName() const bool QPrinterInfo::isNull() const { const Q_D(QPrinterInfo); - return d->isNull; + return d == &QPrinterInfoPrivate::shared_null; } /*! diff --git a/src/gui/painting/qprinterinfo_p.h b/src/gui/painting/qprinterinfo_p.h index f5981d4..7781d59 100644 --- a/src/gui/painting/qprinterinfo_p.h +++ b/src/gui/painting/qprinterinfo_p.h @@ -65,7 +65,7 @@ class QPrinterInfoPrivate { public: QPrinterInfoPrivate(const QString& name = QString()) : - name(name), isNull(false), isDefault(false) + name(name), isDefault(false) #if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_SYMBIAN)) || defined(Q_WS_QPA) #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) , cupsPrinterIndex(0), hasPaperSizes(false) @@ -78,7 +78,6 @@ public: static QPrinterInfoPrivate shared_null; QString name; - bool isNull; bool isDefault; #if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_SYMBIAN)) || defined(Q_WS_QPA) -- cgit v0.12 From b24447e0f20db4a40df724476c6542ea44590935 Mon Sep 17 00:00:00 2001 From: axis Date: Mon, 20 Dec 2010 16:09:50 +0100 Subject: Fixed autotest. --- tests/auto/qprinterinfo/tst_qprinterinfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qprinterinfo/tst_qprinterinfo.cpp b/tests/auto/qprinterinfo/tst_qprinterinfo.cpp index c3fad6c..4f767a5 100644 --- a/tests/auto/qprinterinfo/tst_qprinterinfo.cpp +++ b/tests/auto/qprinterinfo/tst_qprinterinfo.cpp @@ -134,7 +134,7 @@ QStringList tst_QPrinterInfo::getPrintersFromSystem() QString output = getOutputFromCommand(command); QStringList list = output.split(QChar::fromLatin1('\n')); - QRegExp reg("^[Pp]rinter ([.a-zA-Z0-9_-]+)"); + QRegExp reg("^[Pp]rinter ([.a-zA-Z0-9-_@]+)"); for (int c = 0; c < list.size(); ++c) { if (reg.indexIn(list[c]) >= 0) { QString printer = reg.cap(1); -- cgit v0.12 From d9c00320a1e1f6aa7d0083b3415704e20e216a1f Mon Sep 17 00:00:00 2001 From: axis Date: Mon, 6 Dec 2010 13:41:51 +0100 Subject: Moved the default dependency targets to default_post.prf. The file that they were in would not be parsed if CONFIG -= qt, but it always needs to be parsed, otherwise apps that don't use Qt will fail the sis file creation. RevBy: Miikka Heikkinen --- mkspecs/features/symbian/default_post.prf | 47 +++++++++++++++++++++++++++++++ mkspecs/features/symbian/qt.prf | 47 ------------------------------- 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/mkspecs/features/symbian/default_post.prf b/mkspecs/features/symbian/default_post.prf index a2ac377..89f655d 100644 --- a/mkspecs/features/symbian/default_post.prf +++ b/mkspecs/features/symbian/default_post.prf @@ -53,6 +53,53 @@ isEmpty(TARGET.UID2) { } } +# Allow .pro files to specify include path(s) to be prepended to the list. +# +# This allows the project to override the default ordering, whereby paths +# relative to $$QMAKE_INCDIR_QT always come first. This ordering can cause +# problems when both the epoc32/include tree and a Qt include directory +# contain a header of the same name - in this case, the Qt header is always +# included by virtue of its path appearing first in the SYSTEMINCLUDE +# directives in the generated MMP file. +# +# To work around this situation, the following line can be added to the .pro +# file: +# PREPEND_INCLUDEPATH = /epoc32/include +# +INCLUDEPATH = $$PREPEND_INCLUDEPATH $$INCLUDEPATH + +# Add dependency to Qt package to all other projects besides Qt libs. +# Note: Qt libs package with full capabilities has UID3 of 0x2001E61C, +# while self-signed version typically has temporary UID3 of 0xE001E61C. +contains(CONFIG, qt):!contains(TARGET.UID3, 0x2001E61C):!contains(TARGET.UID3, 0xE001E61C):isEmpty(QT_LIBINFIX) { + qt_pkg_name = Qt + pkg_depends_qt += \ + "; Default dependency to Qt libraries" \ + "(0x2001E61C), $${QT_MAJOR_VERSION}, $${QT_MINOR_VERSION}, $${QT_PATCH_VERSION}, {$$addLanguageDependentPkgItem(qt_pkg_name)}" + + # Projects linking to webkit need dependency to webkit + contains(QT, webkit): { + # these can be overridden by mkspecs/modules/qt_webkit.pri + isEmpty(QT_WEBKIT_MAJOR_VERSION) { + QT_WEBKIT_MAJOR_VERSION = $${QT_MAJOR_VERSION} + QT_WEBKIT_MINOR_VERSION = $${QT_MINOR_VERSION} + QT_WEBKIT_PATCH_VERSION = $${QT_PATCH_VERSION} + } + + webkit_pkg_name = QtWebKit + pkg_depends_webkit += \ + "; Dependency to Qt Webkit" \ + "(0x200267C2), $${QT_WEBKIT_MAJOR_VERSION}, $${QT_WEBKIT_MINOR_VERSION}, $${QT_WEBKIT_PATCH_VERSION}, {$$addLanguageDependentPkgItem(webkit_pkg_name)}" + } else { + default_deployment.pkg_prerules -= pkg_depends_webkit + } +} else { + default_deployment.pkg_prerules -= pkg_depends_webkit pkg_depends_qt +} + +isEmpty(TARGET.EPOCSTACKSIZE):TARGET.EPOCSTACKSIZE = 0x14000 +isEmpty(TARGET.EPOCHEAPSIZE):TARGET.EPOCHEAPSIZE = 0x020000 0x800000 + # Supports S60 3.1, 3.2, 5.0, Symbian^3, and Symbian^4 by default platform_product_id = S60ProductID platform_product_id = $$addLanguageDependentPkgItem(platform_product_id) diff --git a/mkspecs/features/symbian/qt.prf b/mkspecs/features/symbian/qt.prf index c8f97aa..c376b64 100644 --- a/mkspecs/features/symbian/qt.prf +++ b/mkspecs/features/symbian/qt.prf @@ -6,53 +6,6 @@ CONFIG += qtmain load(qt) -# Allow .pro files to specify include path(s) to be prepended to the list. -# -# This allows the project to override the default ordering, whereby paths -# relative to $$QMAKE_INCDIR_QT always come first. This ordering can cause -# problems when both the epoc32/include tree and a Qt include directory -# contain a header of the same name - in this case, the Qt header is always -# included by virtue of its path appearing first in the SYSTEMINCLUDE -# directives in the generated MMP file. -# -# To work around this situation, the following line can be added to the .pro -# file: -# PREPEND_INCLUDEPATH = /epoc32/include -# -INCLUDEPATH = $$PREPEND_INCLUDEPATH $$INCLUDEPATH - -# Add dependency to Qt package to all other projects besides Qt libs. -# Note: Qt libs package with full capabilities has UID3 of 0x2001E61C, -# while self-signed version typically has temporary UID3 of 0xE001E61C. -contains(CONFIG, qt):!contains(TARGET.UID3, 0x2001E61C):!contains(TARGET.UID3, 0xE001E61C):isEmpty(QT_LIBINFIX) { - qt_pkg_name = Qt - pkg_depends_qt += \ - "; Default dependency to Qt libraries" \ - "(0x2001E61C), $${QT_MAJOR_VERSION}, $${QT_MINOR_VERSION}, $${QT_PATCH_VERSION}, {$$addLanguageDependentPkgItem(qt_pkg_name)}" - - # Projects linking to webkit need dependency to webkit - contains(QT, webkit): { - # these can be overridden by mkspecs/modules/qt_webkit.pri - isEmpty(QT_WEBKIT_MAJOR_VERSION) { - QT_WEBKIT_MAJOR_VERSION = $${QT_MAJOR_VERSION} - QT_WEBKIT_MINOR_VERSION = $${QT_MINOR_VERSION} - QT_WEBKIT_PATCH_VERSION = $${QT_PATCH_VERSION} - } - - webkit_pkg_name = QtWebKit - pkg_depends_webkit += \ - "; Dependency to Qt Webkit" \ - "(0x200267C2), $${QT_WEBKIT_MAJOR_VERSION}, $${QT_WEBKIT_MINOR_VERSION}, $${QT_WEBKIT_PATCH_VERSION}, {$$addLanguageDependentPkgItem(webkit_pkg_name)}" - } else { - default_deployment.pkg_prerules -= pkg_depends_webkit - } -} else { - default_deployment.pkg_prerules -= pkg_depends_webkit pkg_depends_qt -} - -isEmpty(TARGET.EPOCSTACKSIZE):TARGET.EPOCSTACKSIZE = 0x14000 -isEmpty(TARGET.EPOCHEAPSIZE):TARGET.EPOCHEAPSIZE = 0x020000 0x800000 - # Workaround for the fact that Gnupoc and Symbian chose different approaches to # the letter casing of headers. contains(CONFIG, is_using_gnupoc) { -- cgit v0.12 From 2a340b56c9935ee25bbd0b750d1239cb14051b27 Mon Sep 17 00:00:00 2001 From: axis Date: Tue, 21 Dec 2010 10:46:26 +0100 Subject: Fixed PREPEND_INCLUDEPATH being executed too early. It used to be carried out inside qt.prf, but was moved to default_post.prf. However, since qt.prf is executed after default_post.prf, it would still prepend its own include paths at the very front, which is wrong. Fixed by introducing a new feature profile for PREPEND_INCLUDEPATH, which is run after qt.prf (features in $$CONFIG are executed in reverse order). RevBy: Miikka Heikkinen --- mkspecs/common/symbian/symbian.conf | 2 +- mkspecs/features/symbian/default_post.prf | 15 --------------- mkspecs/features/symbian/prepend_includepath.prf | 14 ++++++++++++++ 3 files changed, 15 insertions(+), 16 deletions(-) create mode 100644 mkspecs/features/symbian/prepend_includepath.prf diff --git a/mkspecs/common/symbian/symbian.conf b/mkspecs/common/symbian/symbian.conf index b8e1d26..8c79d8b 100644 --- a/mkspecs/common/symbian/symbian.conf +++ b/mkspecs/common/symbian/symbian.conf @@ -3,7 +3,7 @@ # TEMPLATE = app -CONFIG += qt warn_on release incremental link_prl sis_targets run_on_phone +CONFIG += prepend_includepath qt warn_on release incremental link_prl sis_targets run_on_phone QT += core gui QMAKE_INCREMENTAL_STYLE = sublib diff --git a/mkspecs/features/symbian/default_post.prf b/mkspecs/features/symbian/default_post.prf index 89f655d..fffc481 100644 --- a/mkspecs/features/symbian/default_post.prf +++ b/mkspecs/features/symbian/default_post.prf @@ -53,21 +53,6 @@ isEmpty(TARGET.UID2) { } } -# Allow .pro files to specify include path(s) to be prepended to the list. -# -# This allows the project to override the default ordering, whereby paths -# relative to $$QMAKE_INCDIR_QT always come first. This ordering can cause -# problems when both the epoc32/include tree and a Qt include directory -# contain a header of the same name - in this case, the Qt header is always -# included by virtue of its path appearing first in the SYSTEMINCLUDE -# directives in the generated MMP file. -# -# To work around this situation, the following line can be added to the .pro -# file: -# PREPEND_INCLUDEPATH = /epoc32/include -# -INCLUDEPATH = $$PREPEND_INCLUDEPATH $$INCLUDEPATH - # Add dependency to Qt package to all other projects besides Qt libs. # Note: Qt libs package with full capabilities has UID3 of 0x2001E61C, # while self-signed version typically has temporary UID3 of 0xE001E61C. diff --git a/mkspecs/features/symbian/prepend_includepath.prf b/mkspecs/features/symbian/prepend_includepath.prf new file mode 100644 index 0000000..d9fd4fe --- /dev/null +++ b/mkspecs/features/symbian/prepend_includepath.prf @@ -0,0 +1,14 @@ +# Allow .pro files to specify include path(s) to be prepended to the list. +# +# This allows the project to override the default ordering, whereby paths +# relative to $$QMAKE_INCDIR_QT always come first. This ordering can cause +# problems when both the epoc32/include tree and a Qt include directory +# contain a header of the same name - in this case, the Qt header is always +# included by virtue of its path appearing first in the SYSTEMINCLUDE +# directives in the generated MMP file. +# +# To work around this situation, the following line can be added to the .pro +# file: +# PREPEND_INCLUDEPATH = /epoc32/include +# +INCLUDEPATH = $$PREPEND_INCLUDEPATH $$INCLUDEPATH -- cgit v0.12