fix: 修复 Deepin/UOS 上始终认为开发者模式未打开的问题

读取 /var/lib/deepin/developer-mode/enabled 文件之前,QFile 未 open

Log: 判断条件中添加 QFile::open 操作;去除没啥意义的 QTextStream,直接使用 QIODevice::readLine 读取文件第一行
This commit is contained in:
zty199 2022-12-31 22:03:05 +08:00
parent fc658f324d
commit 4120af7e24

@ -71,12 +71,11 @@ int main(int argc, char *argv[])
// Check UOS developer mode.
QFile UOSDevelopFile(UOSCheckFile);
if (UOSDevelopFile.exists() && isDeepinOS)
if (isDeepinOS && UOSDevelopFile.exists() && UOSDevelopFile.open(QFile::ReadOnly | QFile::Text))
{
config.setValue("UOS/isUOS", true);
QTextStream UOStextStream(&UOSDevelopFile);
QString lineData = UOStextStream.readLine();
bool devmode = lineData.toInt();
QString lineData = UOSDevelopFile.readLine();
bool devmode = lineData.trimmed().toInt();
qDebug() << "UOS Developer Mode Status:" << devmode;
config.setValue("UOS/EnableDeveloperMode", devmode);
}
@ -88,6 +87,7 @@ int main(int argc, char *argv[])
config.remove("UOS/EnableDeveloperMode");
}
}
UOSDevelopFile.close();
config.sync(); // 写入更改至 config.ini并同步最新内容
// 龙芯机器配置,使得 DApplication 能正确加载 QTWEBENGINE