From 23207d1d2386d97b9d27f2af385d70f80c14ab95 Mon Sep 17 00:00:00 2001 From: Sune Vuorela Date: Sun, 16 Dec 2018 13:52:45 +0100 Subject: Empty filenames does not exist If empty paths is passed to the unix filesystem engine, we get a warning about empty filename passed to function, before returning false. Fix this by testing for empty string first, and don't send empty string to file engine. The current warning leads to code like if (!filename.isEmpty() && QFile::exists(filename)) { // } rather than the slightly cleaner if (QFile::exists(filename)) { // } Change-Id: I0207324889ec22e5a072c28d58337d117b0153b1 Reviewed-by: Thiago Macieira Reviewed-by: Mitch Curtis --- src/corelib/io/qfileinfo.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 26078a6c71..185e061d8f 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -703,6 +703,8 @@ bool QFileInfo::exists() const */ bool QFileInfo::exists(const QString &file) { + if (file.isEmpty()) + return false; QFileSystemEntry entry(file); QFileSystemMetaData data; QAbstractFileEngine *engine = -- cgit v1.2.3