QStorageInfo/Unix: reset the valid state when doStat()ing again
If the user calls setPath() or refresh(), we are going to stat the storage again. But neither retrieveVolumeInfo() nor initRootPath() unset the flag if the storage became invalid. This can't be tested automatically. Fixes: QTBUG-129689 Pick-to: 6.5 6.2 5.15 Change-Id: I8d4c5b4ed563e89f5723fffd2f550b169bb20884 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> (cherry picked from commit e55d7fa1e09efc86e797efdf00656891f640d81d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
8058a77340
commit
20bf08f012
@ -197,10 +197,8 @@ void QStorageInfoPrivate::retrieveVolumeInfo()
|
||||
struct statfs64 statfs_buf;
|
||||
int result;
|
||||
QT_EINTR_LOOP(result, statfs64(QFile::encodeName(rootPath).constData(), &statfs_buf));
|
||||
if (result == 0) {
|
||||
valid = true;
|
||||
ready = true;
|
||||
|
||||
valid = ready = (result == 0);
|
||||
if (valid) {
|
||||
bytesTotal = statfs_buf.f_blocks * statfs_buf.f_frsize;
|
||||
bytesFree = statfs_buf.f_bfree * statfs_buf.f_frsize;
|
||||
bytesAvailable = statfs_buf.f_bavail * statfs_buf.f_frsize;
|
||||
|
@ -390,6 +390,7 @@ static inline QString retrieveLabel(const QByteArray &device)
|
||||
|
||||
void QStorageInfoPrivate::doStat()
|
||||
{
|
||||
valid = ready = false;
|
||||
initRootPath();
|
||||
if (rootPath.isEmpty())
|
||||
return;
|
||||
@ -403,10 +404,8 @@ void QStorageInfoPrivate::retrieveVolumeInfo()
|
||||
QT_STATFSBUF statfs_buf;
|
||||
int result;
|
||||
QT_EINTR_LOOP(result, QT_STATFS(QFile::encodeName(rootPath).constData(), &statfs_buf));
|
||||
if (result == 0) {
|
||||
valid = true;
|
||||
ready = true;
|
||||
|
||||
valid = ready = (result == 0);
|
||||
if (valid) {
|
||||
#if defined(Q_OS_INTEGRITY) || (defined(Q_OS_BSD4) && !defined(Q_OS_NETBSD)) || defined(Q_OS_RTEMS)
|
||||
bytesTotal = statfs_buf.f_blocks * statfs_buf.f_bsize;
|
||||
bytesFree = statfs_buf.f_bfree * statfs_buf.f_bsize;
|
||||
|
Loading…
x
Reference in New Issue
Block a user