summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-07-25 21:36:38 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-07-25 21:36:38 (GMT)
commit32fe76c36a9cb0ec5121e43e78032b862d5286f3 (patch)
tree5efe71302f85ea34590951d0f65faf1c3ef96488
parenta847edefd9e2efd70e63935965624354406f932d (diff)
parentc00b6a953d08fe9b13fa61f1e4acdb937885aa03 (diff)
downloadQt-32fe76c36a9cb0ec5121e43e78032b862d5286f3.zip
Qt-32fe76c36a9cb0ec5121e43e78032b862d5286f3.tar.gz
Qt-32fe76c36a9cb0ec5121e43e78032b862d5286f3.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2: Stabilize tst_qlineedit.cpp QScriptEngineAgent: ensure that the top of the backtrace is correct in exceptionThrow Fix QLineEdit's Highlight color when inactive.
-rw-r--r--src/gui/kernel/qpalette.cpp10
-rw-r--r--src/gui/widgets/qlineedit.cpp3
-rw-r--r--src/script/api/qscriptengineagent.cpp3
-rw-r--r--tests/auto/qlineedit/tst_qlineedit.cpp26
-rw-r--r--tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp83
5 files changed, 123 insertions, 2 deletions
diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp
index 98e8f66..38ec806 100644
--- a/src/gui/kernel/qpalette.cpp
+++ b/src/gui/kernel/qpalette.cpp
@@ -868,11 +868,21 @@ void QPalette::detach()
Returns true (slowly) if this palette is different from \a p;
otherwise returns false (usually quickly).
+
+ \note The current ColorGroup is not taken into account when
+ comparing palettes
+
+ \sa operator==
*/
/*!
Returns true (usually quickly) if this palette is equal to \a p;
otherwise returns false (slowly).
+
+ \note The current ColorGroup is not taken into account when
+ comparing palettes
+
+ \sa operator!=
*/
bool QPalette::operator==(const QPalette &p) const
{
diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp
index d7311ef..981e934 100644
--- a/src/gui/widgets/qlineedit.cpp
+++ b/src/gui/widgets/qlineedit.cpp
@@ -1949,7 +1949,8 @@ void QLineEdit::paintEvent(QPaintEvent *)
if (d->control->hasSelectedText() || (d->cursorVisible && !d->control->inputMask().isEmpty() && !d->control->isReadOnly())){
flags |= QLineControl::DrawSelections;
// Palette only used for selections/mask and may not be in sync
- if(d->control->palette() != pal)
+ if (d->control->palette() != pal
+ || d->control->palette().currentColorGroup() != pal.currentColorGroup())
d->control->setPalette(pal);
}
diff --git a/src/script/api/qscriptengineagent.cpp b/src/script/api/qscriptengineagent.cpp
index 28905e8..0b5828a 100644
--- a/src/script/api/qscriptengineagent.cpp
+++ b/src/script/api/qscriptengineagent.cpp
@@ -134,9 +134,12 @@ void QScriptEngineAgentPrivate::returnEvent(const JSC::DebuggerCallFrame& frame,
void QScriptEngineAgentPrivate::exceptionThrow(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, bool hasHandler)
{
JSC::CallFrame *oldFrame = engine->currentFrame;
+ int oldAgentLineNumber = engine->agentLineNumber;
engine->currentFrame = frame.callFrame();
QScriptValue value(engine->scriptValueFromJSCValue(frame.exception()));
+ engine->agentLineNumber = value.property(QLatin1String("lineNumber")).toInt32();
q_ptr->exceptionThrow(sourceID, value, hasHandler);
+ engine->agentLineNumber = oldAgentLineNumber;
engine->currentFrame = oldFrame;
engine->setCurrentException(value);
};
diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp
index b34e559..8951130 100644
--- a/tests/auto/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/qlineedit/tst_qlineedit.cpp
@@ -66,7 +66,6 @@
#include <qspinbox.h>
#include <qdebug.h>
-
//TESTED_CLASS=
//TESTED_FILES=
@@ -275,6 +274,7 @@ private slots:
void taskQTBUG_7902_contextMenuCrash();
#endif
void taskQTBUG_7395_readOnlyShortcut();
+ void QTBUG697_paletteCurrentColorGroup();
#ifdef QT3_SUPPORT
void validateAndSet_data();
@@ -3714,5 +3714,29 @@ void tst_QLineEdit::taskQTBUG_7395_readOnlyShortcut()
QCOMPARE(spy.count(), 1);
}
+void tst_QLineEdit::QTBUG697_paletteCurrentColorGroup()
+{
+ QLineEdit le;
+ le.setText(" ");
+ QPalette p = le.palette();
+ p.setBrush(QPalette::Active, QPalette::Highlight, Qt::green);
+ p.setBrush(QPalette::Inactive, QPalette::Highlight, Qt::red);
+ le.setPalette(p);
+
+ le.show();
+ QApplication::setActiveWindow(&le);
+ QTest::qWaitForWindowShown(&le);
+ le.setFocus();
+ QTRY_VERIFY(le.hasFocus());
+ le.selectAll();
+
+ QImage img(le.size(),QImage::Format_ARGB32 );
+ le.render(&img);
+ QCOMPARE(img.pixel(10, le.height()/2), QColor(Qt::green).rgb());
+ QApplication::setActiveWindow(0);
+ le.render(&img);
+ QCOMPARE(img.pixel(10, le.height()/2), QColor(Qt::red).rgb());
+}
+
QTEST_MAIN(tst_QLineEdit)
#include "tst_qlineedit.moc"
diff --git a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp
index a0f10dd..ed00b96 100644
--- a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp
+++ b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp
@@ -116,6 +116,8 @@ private slots:
void evaluateProgram_SyntaxError();
void evaluateNullProgram();
void QTBUG6108();
+ void backtraces_data();
+ void backtraces();
private:
double m_testProperty;
@@ -2379,5 +2381,86 @@ void tst_QScriptEngineAgent::QTBUG6108()
QCOMPARE(spy->at(4).scriptId, spy->at(0).scriptId);
}
+class BacktraceSpy : public QScriptEngineAgent
+{
+public:
+ BacktraceSpy(QScriptEngine *engine, const QStringList &expectedbacktrace, int breakpoint)
+ : QScriptEngineAgent(engine), expectedbacktrace(expectedbacktrace), breakpoint(breakpoint), ok(false) {}
+
+ QStringList expectedbacktrace;
+ int breakpoint;
+ bool ok;
+
+protected:
+
+ void exceptionThrow(qint64 , const QScriptValue &, bool)
+ { check(); }
+
+ void positionChange(qint64 , int lineNumber, int )
+ {
+ if (lineNumber == breakpoint)
+ check();
+ }
+
+private:
+ void check()
+ {
+ QCOMPARE(engine()->currentContext()->backtrace(), expectedbacktrace);
+ ok = true;
+ }
+};
+
+
+void tst_QScriptEngineAgent::backtraces_data()
+{
+ QTest::addColumn<QString>("code");
+ QTest::addColumn<int>("breakpoint");
+ QTest::addColumn<QStringList>("expectedbacktrace");
+
+ {
+ QString source(
+ "function foo() {\n"
+ " var a = 5\n"
+ "}\n"
+ "foo('hello', { })\n"
+ "var r = 0;");
+
+ QStringList expected;
+ expected
+ << "foo('hello', [object Object]) at filename.js:2"
+ << "<global>() at filename.js:4";
+ QTest::newRow("simple breakpoint") << source << 2 << expected;
+ }
+
+ {
+ QString source(
+ "function foo() {\n"
+ " error = err\n" //this must throw
+ "}\n"
+ "foo('hello', { })\n"
+ "var r = 0;");
+
+ QStringList expected;
+ expected
+ << "foo('hello', [object Object]) at filename.js:2"
+ << "<global>() at filename.js:4";
+ QTest::newRow("throw because of error") << source << -100 << expected;
+ }
+}
+
+void tst_QScriptEngineAgent::backtraces()
+{
+ QFETCH(QString, code);
+ QFETCH(int, breakpoint);
+ QFETCH(QStringList, expectedbacktrace);
+
+ QScriptEngine eng;
+ BacktraceSpy *spy = new BacktraceSpy(&eng, expectedbacktrace, breakpoint);
+ eng.setAgent(spy);
+ QLatin1String filename("filename.js");
+ eng.evaluate(code, filename);
+ QVERIFY(spy->ok);
+}
+
QTEST_MAIN(tst_QScriptEngineAgent)
#include "tst_qscriptengineagent.moc"