mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-01 07:05:48 +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
|
||||
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());
|
||||
cmdline.close();
|
||||
if (content.contains("boot=live")) {
|
||||
|
@ -343,6 +343,8 @@ qint64 ShutdownPlugin::get_power_image_size()
|
||||
if (file.open(QIODevice::Text | QIODevice::ReadOnly)) {
|
||||
size = file.readAll().trimmed().toLongLong();
|
||||
file.close();
|
||||
} else{
|
||||
qWarning() << "open /sys/power/image_size failed! please check permission!!!";
|
||||
}
|
||||
|
||||
return size;
|
||||
@ -374,7 +376,7 @@ bool ShutdownPlugin::checkSwap()
|
||||
|
||||
file.close();
|
||||
} else {
|
||||
qDebug() << "open /proc/swaps failed! please check permission!!!";
|
||||
qWarning() << "open /proc/swaps failed! please check permission!!!";
|
||||
}
|
||||
|
||||
return hasSwap;
|
||||
|
Loading…
x
Reference in New Issue
Block a user