mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
File descriptor fixes for XDPOpenWithDialog
- Open it with O_CLOEXEC - Remove unneseccary std::array complication - Rely on Gio::UnixFDList to close it
This commit is contained in:
parent
a6fcc6d51d
commit
88e742927f
2 changed files with 4 additions and 5 deletions
|
@ -44,14 +44,12 @@ bool UnsafeShowOpenWith(const QString &filepath) {
|
||||||
|
|
||||||
const auto fd = open(
|
const auto fd = open(
|
||||||
QFile::encodeName(filepath).constData(),
|
QFile::encodeName(filepath).constData(),
|
||||||
O_RDONLY);
|
O_RDONLY | O_CLOEXEC);
|
||||||
|
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto fdGuard = gsl::finally([&] { close(fd); });
|
|
||||||
|
|
||||||
const auto handleToken = "tdesktop"
|
const auto handleToken = "tdesktop"
|
||||||
+ std::to_string(base::RandomValue<uint>());
|
+ std::to_string(base::RandomValue<uint>());
|
||||||
|
|
||||||
|
@ -73,6 +71,7 @@ bool UnsafeShowOpenWith(const QString &filepath) {
|
||||||
nullptr));
|
nullptr));
|
||||||
|
|
||||||
if (!request) {
|
if (!request) {
|
||||||
|
close(fd);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +106,7 @@ bool UnsafeShowOpenWith(const QString &filepath) {
|
||||||
GLib::Variant::new_variant(
|
GLib::Variant::new_variant(
|
||||||
GLib::Variant::new_boolean(true))),
|
GLib::Variant::new_boolean(true))),
|
||||||
}),
|
}),
|
||||||
Gio::UnixFDList::new_from_array((std::array{ fd }).data(), 1),
|
Gio::UnixFDList::new_from_array(&fd, 1),
|
||||||
nullptr);
|
nullptr);
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit e2c62ef0b4581d84e4ff79623a7e5e9ed315bad7
|
Subproject commit 4d56f8b4bba52b46844f46fafa5f9b6b2704429e
|
Loading…
Add table
Reference in a new issue