修复一处gio资源释放问题;

This commit is contained in:
jixiaoxu 2022-03-07 11:38:03 +08:00 committed by iaom
parent f356ca340a
commit 577d4f6050
1 changed files with 13 additions and 8 deletions

View File

@ -773,6 +773,7 @@ void FileUtils::getTxtContent(QString &path, QString &textcontent) {
int FileUtils::openFile(QString &path, bool openInDir)
{
int res = -1;
if(openInDir) {
QStringList list;
list.append(path);
@ -781,12 +782,12 @@ int FileUtils::openFile(QString &path, bool openInDir)
"org.freedesktop.FileManager1",
"ShowItems");
message.setArguments({list, "ukui-search"});
QDBusMessage res = QDBusConnection::sessionBus().call(message);
if (QDBusMessage::ReplyMessage == res.ReplyMessage) {
return 0;
QDBusMessage messageRes = QDBusConnection::sessionBus().call(message);
if (QDBusMessage::ReplyMessage == messageRes.ReplyMessage) {
res = 0;
} else {
qDebug() << "Error! QDBusMessage reply error! ReplyMessage:" << res.ReplyMessage;
return -1;
qDebug() << "Error! QDBusMessage reply error! ReplyMessage:" << messageRes.ReplyMessage;
res = -1;
}
} else {
auto file = wrapGFile(g_file_new_for_uri(QUrl::fromLocalFile(path).toString().toUtf8().constData()));
@ -801,6 +802,7 @@ int FileUtils::openFile(QString &path, bool openInDir)
mimeType = g_file_info_get_attribute_string(fileInfo.get()->get(), "standard::fast-content-type");
}
}
GError *error = NULL;
GAppInfo *info = NULL;
/*
@ -826,11 +828,14 @@ int FileUtils::openFile(QString &path, bool openInDir)
}
g_key_file_free (keyfile);
if(!G_IS_APP_INFO(info)) {
return -1;
res = -1;
} else {
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
res = 0;
}
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
return 0;
g_object_unref(info);
}
return res;
}
bool FileUtils::copyPath(QString &path)