diff --git a/src/corelib/io/qstorageinfo_linux.cpp b/src/corelib/io/qstorageinfo_linux.cpp index e1f7fe65ac3..40e3cafd5a6 100644 --- a/src/corelib/io/qstorageinfo_linux.cpp +++ b/src/corelib/io/qstorageinfo_linux.cpp @@ -229,11 +229,9 @@ quint64 QStorageInfoPrivate::initRootPath() for (auto it = infos.rbegin(); it != infos.rend(); ++it) { if (rootPathDevId != it->stDev || !isParentOf(it->mountPoint, oldRootPath)) continue; - rootPath = std::move(it->mountPoint); - device = std::move(it->device); - fileSystemType = std::move(it->fsType); - subvolume = std::move(it->fsRoot); - return it->stDev; + auto stDev = it->stDev; + setFromMountInfo(std::move(*it)); + return stDev; } return 0; } diff --git a/src/corelib/io/qstorageinfo_p.h b/src/corelib/io/qstorageinfo_p.h index 9b3b52d8593..e133c20cb49 100644 --- a/src/corelib/io/qstorageinfo_p.h +++ b/src/corelib/io/qstorageinfo_p.h @@ -67,13 +67,20 @@ public: QByteArray fsRoot; dev_t stDev = 0; }; - QStorageInfoPrivate(MountInfo &&info) - : rootPath(std::move(info.mountPoint)), - device(std::move(info.device)), - subvolume(std::move(info.fsRoot)), - fileSystemType(std::move(info.fsType)) + + void setFromMountInfo(MountInfo &&info) { + rootPath = std::move(info.mountPoint); + fileSystemType = std::move(info.fsType); + device = std::move(info.device); + subvolume = std::move(info.fsRoot); } + + QStorageInfoPrivate(MountInfo &&info) + { + setFromMountInfo(std::move(info)); + } + #elif defined(Q_OS_UNIX) void initRootPath(); void retrieveVolumeInfo();