From dbd16b3b6d2e6b030dd52e90eb3a38dc1a73c180 Mon Sep 17 00:00:00 2001 From: Zeno Albisser Date: Thu, 3 Jun 2010 16:54:31 +0200 Subject: fix for using .lnk files when running app from UNC Since "" is an invalid target for a .lnk file, we can return false for doStat() in case of resolving the .lnk to "". Notice that .lnk files only allow absolute paths for the target. "" is returned by readLink in case the .lnk file does not exist. Reviewed-by: Joao Task-Number: QTBUG-10863 --- src/corelib/io/qfsfileengine_win.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index ec49f1a..21930e1 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -1162,7 +1162,15 @@ bool QFSFileEnginePrivate::doStat() const if (filePath.isEmpty()) return could_stat; - QString fname = filePath.endsWith(QLatin1String(".lnk")) ? readLink(filePath) : filePath; + QString fname; + if(filePath.endsWith(QLatin1String(".lnk"))) { + fname = readLink(filePath); + if(fname.isEmpty()) + return could_stat; + } + else + fname = filePath; + fname = fixIfRelativeUncPath(fname); UINT oldmode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); -- cgit v0.12 From cd8a6d6836f04f66d3e7083c97f7873240afa433 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Fri, 4 Jun 2010 12:53:36 +0200 Subject: Avoid timer starvation during high posted event activity Similar to commit bc01bb10da23d0d2308cf02a16947be836bc9a21, we need to avoid starvation of the idle time source by forcing a single, normal priority pass after processing posted events. Reviewed-by: ogoffart Task-number: QT-3467 --- src/corelib/kernel/qeventdispatcher_glib.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/corelib/kernel/qeventdispatcher_glib.cpp b/src/corelib/kernel/qeventdispatcher_glib.cpp index fd36be4..9c1c827 100644 --- a/src/corelib/kernel/qeventdispatcher_glib.cpp +++ b/src/corelib/kernel/qeventdispatcher_glib.cpp @@ -246,6 +246,7 @@ struct GPostEventSource GSource source; QAtomicInt serialNumber; int lastSerialNumber; + QEventDispatcherGlibPrivate *d; }; static gboolean postEventSourcePrepare(GSource *s, gint *timeout) @@ -274,6 +275,7 @@ static gboolean postEventSourceDispatch(GSource *s, GSourceFunc, gpointer) GPostEventSource *source = reinterpret_cast(s); source->lastSerialNumber = source->serialNumber; QCoreApplication::sendPostedEvents(); + source->d->runTimersOnceWithNormalPriority(); return true; // i dunno, george... } @@ -313,6 +315,7 @@ QEventDispatcherGlibPrivate::QEventDispatcherGlibPrivate(GMainContext *context) postEventSource = reinterpret_cast(g_source_new(&postEventSourceFuncs, sizeof(GPostEventSource))); postEventSource->serialNumber = 1; + postEventSource->d = this; g_source_set_can_recurse(&postEventSource->source, true); g_source_attach(&postEventSource->source, mainContext); -- cgit v0.12 From 2b4d2fd1ada524f4780dd7633ca34bc72d823ff1 Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Fri, 4 Jun 2010 18:37:00 +0200 Subject: Fix in Addressbook tutorial Don't add if name or address is empty. Reviewed-by: Alessandro Portale --- examples/tutorials/addressbook/part3/addressbook.cpp | 1 + examples/tutorials/addressbook/part4/addressbook.cpp | 1 + examples/tutorials/addressbook/part5/addressbook.cpp | 1 + examples/tutorials/addressbook/part6/addressbook.cpp | 1 + examples/tutorials/addressbook/part7/addressbook.cpp | 1 + 5 files changed, 5 insertions(+) diff --git a/examples/tutorials/addressbook/part3/addressbook.cpp b/examples/tutorials/addressbook/part3/addressbook.cpp index adb87ef..28a570a 100644 --- a/examples/tutorials/addressbook/part3/addressbook.cpp +++ b/examples/tutorials/addressbook/part3/addressbook.cpp @@ -125,6 +125,7 @@ void AddressBook::submitContact() if (name == "" || address == "") { QMessageBox::information(this, tr("Empty Field"), tr("Please enter a name and address.")); + return; } if (!contacts.contains(name)) { diff --git a/examples/tutorials/addressbook/part4/addressbook.cpp b/examples/tutorials/addressbook/part4/addressbook.cpp index 1b7a6c4..55d551f 100644 --- a/examples/tutorials/addressbook/part4/addressbook.cpp +++ b/examples/tutorials/addressbook/part4/addressbook.cpp @@ -134,6 +134,7 @@ void AddressBook::submitContact() if (name == "" || address == "") { QMessageBox::information(this, tr("Empty Field"), tr("Please enter a name and address.")); + return; } //! [submitContact() function part1] if (currentMode == AddingMode) { diff --git a/examples/tutorials/addressbook/part5/addressbook.cpp b/examples/tutorials/addressbook/part5/addressbook.cpp index 80c18c3..1b3f451 100644 --- a/examples/tutorials/addressbook/part5/addressbook.cpp +++ b/examples/tutorials/addressbook/part5/addressbook.cpp @@ -141,6 +141,7 @@ void AddressBook::submitContact() if (name == "" || address == "") { QMessageBox::information(this, tr("Empty Field"), tr("Please enter a name and address.")); + return; } if (currentMode == AddingMode) { diff --git a/examples/tutorials/addressbook/part6/addressbook.cpp b/examples/tutorials/addressbook/part6/addressbook.cpp index fc41190..724971c 100644 --- a/examples/tutorials/addressbook/part6/addressbook.cpp +++ b/examples/tutorials/addressbook/part6/addressbook.cpp @@ -147,6 +147,7 @@ void AddressBook::submitContact() if (name == "" || address == "") { QMessageBox::information(this, tr("Empty Field"), tr("Please enter a name and address.")); + return; } if (currentMode == AddingMode) { diff --git a/examples/tutorials/addressbook/part7/addressbook.cpp b/examples/tutorials/addressbook/part7/addressbook.cpp index 3ab8702..bf00298 100644 --- a/examples/tutorials/addressbook/part7/addressbook.cpp +++ b/examples/tutorials/addressbook/part7/addressbook.cpp @@ -149,6 +149,7 @@ void AddressBook::submitContact() if (name == "" || address == "") { QMessageBox::information(this, tr("Empty Field"), tr("Please enter a name and address.")); + return; } if (currentMode == AddingMode) { -- cgit v0.12 From 09c6a81109d3978c1583c556202c01c1e774f11f Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 4 Jun 2010 20:47:46 +0200 Subject: Make qbswap() use glibc's fast bswap_*() functions if available. Reviewed-by: Thiago Macieira --- src/corelib/global/qendian.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/corelib/global/qendian.h b/src/corelib/global/qendian.h index 107854c..353e8b9 100644 --- a/src/corelib/global/qendian.h +++ b/src/corelib/global/qendian.h @@ -42,6 +42,16 @@ #ifndef QENDIAN_H #define QENDIAN_H +#ifdef Q_OS_LINUX +QT_BEGIN_INCLUDE_NAMESPACE +# include +QT_END_INCLUDE_NAMESPACE +#endif + +#ifdef __GLIBC__ +#include +#endif + #include QT_BEGIN_HEADER @@ -264,6 +274,21 @@ template <> inline qint16 qFromBigEndian(const uchar *src) * and it is therefore a bit more convenient and in most cases more efficient. */ template T qbswap(T source); + +#ifdef __GLIBC__ +template <> inline quint64 qbswap(quint64 source) +{ + return bswap_64(source); +} +template <> inline quint32 qbswap(quint32 source) +{ + return bswap_32(source); +} +template <> inline quint16 qbswap(quint16 source) +{ + return bswap_16(source); +} +#else template <> inline quint64 qbswap(quint64 source) { return 0 @@ -292,6 +317,7 @@ template <> inline quint16 qbswap(quint16 source) | ((source & 0x00ff) << 8) | ((source & 0xff00) >> 8) ); } +#endif // __GLIBC__ // signed specializations template <> inline qint64 qbswap(qint64 source) -- cgit v0.12 From 51fa7df978d71a366c95c732d6a8c2576690d63a Mon Sep 17 00:00:00 2001 From: David Faure Date: Sat, 5 Jun 2010 00:06:15 +0200 Subject: Add convenience constructor to QTextOption::Tab Merge-request: 1734 Reviewed-by: Simon Hausmann --- src/gui/text/qtextoption.cpp | 10 ++++++++-- src/gui/text/qtextoption.h | 2 ++ tests/auto/qtextformat/tst_qtextformat.cpp | 5 +---- tests/auto/qtextlayout/tst_qtextlayout.cpp | 9 ++------- tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp | 9 ++------- 5 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/gui/text/qtextoption.cpp b/src/gui/text/qtextoption.cpp index c1e254c..a2b8022 100644 --- a/src/gui/text/qtextoption.cpp +++ b/src/gui/text/qtextoption.cpp @@ -145,7 +145,7 @@ QTextOption &QTextOption::operator=(const QTextOption &o) \sa tabArray(), setTabStop(), setTabs() */ -void QTextOption::setTabArray(QList tabStops) +void QTextOption::setTabArray(QList tabStops) // Qt5: const ref { if (!d) d = new QTextOptionPrivate; @@ -165,7 +165,7 @@ void QTextOption::setTabArray(QList tabStops) \sa tabStops() */ -void QTextOption::setTabs(QList tabStops) +void QTextOption::setTabs(QList tabStops) // Qt5: const ref { if (!d) d = new QTextOptionPrivate; @@ -391,6 +391,12 @@ QList QTextOption::tabs() const */ /*! + \fn Tab::Tab(qreal pos, TabType tabType, QChar delim = QChar()) + Creates a tab with the given position, tab type, and (for DelimiterTab) delimiter + \since 4.6 +*/ + +/*! \fn bool Tab::operator==(const Tab &other) const Returns true if tab \a other is equal to this tab; diff --git a/src/gui/text/qtextoption.h b/src/gui/text/qtextoption.h index 1381ed1..5af7834 100644 --- a/src/gui/text/qtextoption.h +++ b/src/gui/text/qtextoption.h @@ -68,6 +68,8 @@ public: struct Q_GUI_EXPORT Tab { inline Tab() : position(80), type(QTextOption::LeftTab) { } + inline Tab(qreal pos, TabType tabType, QChar delim = QChar()) + : position(pos), type(tabType), delimiter(delim) {} inline bool operator==(const Tab &other) const { return type == other.type diff --git a/tests/auto/qtextformat/tst_qtextformat.cpp b/tests/auto/qtextformat/tst_qtextformat.cpp index ee1f4b5..9b71481 100644 --- a/tests/auto/qtextformat/tst_qtextformat.cpp +++ b/tests/auto/qtextformat/tst_qtextformat.cpp @@ -308,10 +308,7 @@ void tst_QTextFormat::getSetTabs() format.setTabPositions(tabs); Comparator c2(tabs, format.tabPositions()); - QTextOption::Tab tab2; - tab2.position = 3456; - tab2.type = QTextOption::RightTab; - tab2.delimiter = QChar('x'); + QTextOption::Tab tab2(3456, QTextOption::RightTab, QChar('x')); tabs.append(tab2); format.setTabPositions(tabs); Comparator c3(tabs, format.tabPositions()); diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp index 1a5f493..a631f3d 100644 --- a/tests/auto/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp @@ -980,9 +980,7 @@ void tst_QTextLayout::testCenteredTab() // test if centering the tab works. We expect the center of 'Bar.' to be at the tab point. QTextOption option = layout.textOption(); QList tabs; - QTextOption::Tab tab; - tab.type = QTextOption::CenterTab; - tab.position = 150; + QTextOption::Tab tab(150, QTextOption::CenterTab); tabs.append(tab); option.setTabs(tabs); layout.setTextOption(option); @@ -1002,10 +1000,7 @@ void tst_QTextLayout::testDelimiterTab() // try the different delimiter characters to see if the alignment works there. QTextOption option = layout.textOption(); QList tabs; - QTextOption::Tab tab; - tab.type = QTextOption::DelimiterTab; - tab.delimiter = QChar('.'); - tab.position = 100; + QTextOption::Tab tab(100, QTextOption::DelimiterTab, QChar('.')); tabs.append(tab); option.setTabs(tabs); layout.setTextOption(option); diff --git a/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp b/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp index 64c42bb..a463d86 100644 --- a/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp +++ b/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp @@ -198,14 +198,9 @@ void tst_QTextOdfWriter::testWriteStyle2() { QTextBlockFormat bf; // = cursor.blockFormat(); QList tabs; - QTextOption::Tab tab1; - tab1.position = 40; - tab1.type = QTextOption::RightTab; + QTextOption::Tab tab1(40, QTextOption::RightTab); tabs << tab1; - QTextOption::Tab tab2; - tab2.position = 80; - tab2.type = QTextOption::DelimiterTab; - tab2.delimiter = 'o'; + QTextOption::Tab tab2(80, QTextOption::DelimiterTab, 'o'); tabs << tab2; bf.setTabPositions(tabs); -- cgit v0.12