mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
Fix: optimize QFile operation
Catch QFile open error and add qWarning when fail Log: optimize QFile operation
This commit is contained in:
parent
1b5f9554d1
commit
a1af30c814
@ -145,7 +145,10 @@ bool OverlayWarningPlugin::isOverlayRoot()
|
|||||||
{
|
{
|
||||||
// ignore live/recovery mode
|
// ignore live/recovery mode
|
||||||
QFile cmdline("/proc/cmdline");
|
QFile cmdline("/proc/cmdline");
|
||||||
cmdline.open(QFile::ReadOnly);
|
if (!cmdline.open(QIODevice::ReadOnly)) {
|
||||||
|
qWarning() << "open /proc/cmdline failed! please check permission!!!";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
QString content(cmdline.readAll());
|
QString content(cmdline.readAll());
|
||||||
cmdline.close();
|
cmdline.close();
|
||||||
if (content.contains("boot=live")) {
|
if (content.contains("boot=live")) {
|
||||||
|
@ -343,6 +343,8 @@ qint64 ShutdownPlugin::get_power_image_size()
|
|||||||
if (file.open(QIODevice::Text | QIODevice::ReadOnly)) {
|
if (file.open(QIODevice::Text | QIODevice::ReadOnly)) {
|
||||||
size = file.readAll().trimmed().toLongLong();
|
size = file.readAll().trimmed().toLongLong();
|
||||||
file.close();
|
file.close();
|
||||||
|
} else{
|
||||||
|
qWarning() << "open /sys/power/image_size failed! please check permission!!!";
|
||||||
}
|
}
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
@ -374,7 +376,7 @@ bool ShutdownPlugin::checkSwap()
|
|||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "open /proc/swaps failed! please check permission!!!";
|
qWarning() << "open /proc/swaps failed! please check permission!!!";
|
||||||
}
|
}
|
||||||
|
|
||||||
return hasSwap;
|
return hasSwap;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user