From 9ad1428486298d15f94f2590df13d07e683398c2 Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Sat, 14 Mar 2009 10:47:29 +0000 Subject: [PATCH] Fix an infinite loop with Qt4.5 when creating two unnamed files. In Qt4.5, QFileInfo::operator==() always returns true when comparing two non-existing files. Therefore, an extra check is needed. see http://www.lyx.org/trac/changeset/28748 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@28768 a592a061-630c-0410-9148-cb99ea01b6c8 --- ANNOUNCE | 2 ++ src/support/FileName.cpp | 9 +++++++-- status.16x | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index e5675bf0c4..77bd16aefa 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -269,6 +269,8 @@ What's new in version 1.6.2? - Fix the use of regular expressions to avoid crashes with Qt4.5. +- Fix an infinite loop when creating multiple unnamed files with Qt4.5. + - Ignore the master_buffer setting in Document>Settings if the current document is no real child. This fixes a crash when using the outliner in such files (bug 5653). diff --git a/src/support/FileName.cpp b/src/support/FileName.cpp index 3bedc0475a..1beeb29194 100644 --- a/src/support/FileName.cpp +++ b/src/support/FileName.cpp @@ -944,7 +944,10 @@ bool operator==(FileName const & l, FileName const & r) if (!lhs.d->fi.isSymLink() && !rhs.d->fi.isSymLink()) { // Qt already checks if the filesystem is case sensitive or not. - return lhs.d->fi == rhs.d->fi; + return lhs.d->fi == rhs.d->fi + // This is needed as in Qt4.5, QFileInfo::operator== compares + // the location of the two files and not the files themselves. + && lhs.d->fi.fileName() == rhs.d->fi.fileName(); } // FIXME: When/if QFileInfo support symlink comparison, remove this code. @@ -954,7 +957,9 @@ bool operator==(FileName const & l, FileName const & r) QFileInfo fi2(rhs.d->fi); if (fi2.isSymLink()) fi2 = QFileInfo(fi2.symLinkTarget()); - return fi1 == fi2; + // This is needed as in Qt4.5, QFileInfo::operator== compares + // the location of the two files and not the files themselves. + return fi1 == fi2 && fi1.fileName() == fi2.fileName(); } diff --git a/status.16x b/status.16x index c3d385c7a8..072362a048 100644 --- a/status.16x +++ b/status.16x @@ -213,6 +213,8 @@ What's new - Fix the use of regular expressions to avoid crashes with Qt4.5. +- Fix an infinite loop when creating multiple unnamed files with Qt4.5. + - Ignore the master_buffer setting in Document>Settings if the current document is no real child. This fixes a crash when using the outliner in such files (bug 5653).