summaryrefslogtreecommitdiffstats
path: root/Telegram/SourceFiles/platform/linux/linux_gtk_integration.cpp
diff options
context:
space:
mode:
authorIlya Fedin <fedin-ilja2010@ya.ru>2021-07-03 05:48:35 +0400
committerJohn Preston <johnprestonmail@gmail.com>2021-07-04 20:05:53 +0300
commit75ff7a66373b6a9230bab28b6edf0b8ffb61bf0b (patch)
tree2597df583f62ba53854dc412481d1b0469bd3230 /Telegram/SourceFiles/platform/linux/linux_gtk_integration.cpp
parentaece7c109615c05c5bb6b515a13dcdf8136e93ad (diff)
Control GtkOpenWithDialog lifetime from outside
Diffstat (limited to 'Telegram/SourceFiles/platform/linux/linux_gtk_integration.cpp')
-rw-r--r--Telegram/SourceFiles/platform/linux/linux_gtk_integration.cpp51
1 files changed, 27 insertions, 24 deletions
diff --git a/Telegram/SourceFiles/platform/linux/linux_gtk_integration.cpp b/Telegram/SourceFiles/platform/linux/linux_gtk_integration.cpp
index 3caa9b31a1..74456143f3 100644
--- a/Telegram/SourceFiles/platform/linux/linux_gtk_integration.cpp
+++ b/Telegram/SourceFiles/platform/linux/linux_gtk_integration.cpp
@@ -154,11 +154,28 @@ void GtkIntegration::Private::handleMethodCall(
const auto filepath = base::Platform::GlibVariantCast<
Glib::ustring>(parametersCopy.get_child(1));
- const auto result = File::internal::ShowGtkOpenWithDialog(
+ const auto dialog = File::internal::CreateGtkOpenWithDialog(
QString::fromStdString(parent),
- QString::fromStdString(filepath));
+ QString::fromStdString(filepath)).release();
+
+ if (dialog) {
+ dialog->response(
+ ) | rpl::start_with_next([=](bool response) {
+ try {
+ connection->emit_signal(
+ std::string(kObjectPath),
+ std::string(kInterface),
+ "OpenWithDialogResponse",
+ parentDBusName,
+ base::Platform::MakeGlibVariant(std::tuple{
+ response,
+ }));
+ } catch (...) {
+ }
+
+ delete dialog;
+ }, dialog->lifetime());
- if (result) {
invocation->return_value({});
return;
}
@@ -340,23 +357,6 @@ int GtkIntegration::exec(const QString &parentDBusName, int ppid) {
_private->introspectionData->lookup_interface(),
_private->interfaceVTable);
- rpl::lifetime lifetime;
-
- File::internal::GtkOpenWithDialogResponse(
- ) | rpl::start_with_next([=](bool response) {
- try {
- _private->dbusConnection->emit_signal(
- std::string(kObjectPath),
- std::string(kInterface),
- "OpenWithDialogResponse",
- _private->parentDBusName,
- base::Platform::MakeGlibVariant(std::tuple{
- response,
- }));
- } catch (...) {
- }
- }, lifetime);
-
const auto app = Gio::Application::create(_private->serviceName);
app->hold();
_private->parentServiceWatcherId = base::Platform::DBus::RegisterServiceWatcher(
@@ -459,21 +459,24 @@ bool GtkIntegration::showOpenWithDialog(const QString &filepath) const {
return false;
}
- if (!File::internal::ShowGtkOpenWithDialog(parent, filepath)) {
+ const auto dialog = File::internal::CreateGtkOpenWithDialog(
+ parent,
+ filepath);
+
+ if (!dialog) {
return false;
}
const auto context = Glib::MainContext::create();
const auto loop = Glib::MainLoop::create(context);
g_main_context_push_thread_default(context->gobj());
- rpl::lifetime lifetime;
bool result = false;
- File::internal::GtkOpenWithDialogResponse(
+ dialog->response(
) | rpl::start_with_next([&](bool response) {
result = response;
loop->quit();
- }, lifetime);
+ }, dialog->lifetime());
QWindow window;
QGuiApplicationPrivate::showModalWindow(&window);