mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 13:17:08 +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(
|
||||
QFile::encodeName(filepath).constData(),
|
||||
O_RDONLY);
|
||||
O_RDONLY | O_CLOEXEC);
|
||||
|
||||
if (fd == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto fdGuard = gsl::finally([&] { close(fd); });
|
||||
|
||||
const auto handleToken = "tdesktop"
|
||||
+ std::to_string(base::RandomValue<uint>());
|
||||
|
||||
|
@ -73,6 +71,7 @@ bool UnsafeShowOpenWith(const QString &filepath) {
|
|||
nullptr));
|
||||
|
||||
if (!request) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -107,7 +106,7 @@ bool UnsafeShowOpenWith(const QString &filepath) {
|
|||
GLib::Variant::new_variant(
|
||||
GLib::Variant::new_boolean(true))),
|
||||
}),
|
||||
Gio::UnixFDList::new_from_array((std::array{ fd }).data(), 1),
|
||||
Gio::UnixFDList::new_from_array(&fd, 1),
|
||||
nullptr);
|
||||
|
||||
if (!result) {
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit e2c62ef0b4581d84e4ff79623a7e5e9ed315bad7
|
||||
Subproject commit 4d56f8b4bba52b46844f46fafa5f9b6b2704429e
|
Loading…
Add table
Reference in a new issue