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.8 6.5 6.2 5.15 Change-Id: I8d4c5b4ed563e89f5723fffd2f550b169bb20884 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
This commit is contained in:
parent
ffa0e9c19c
commit
e55d7fa1e0
@ -408,10 +408,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