Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
thunar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Xfce
thunar
Commits
ad8663a4
Commit
ad8663a4
authored
7 years ago
by
Alexander Schwinn
Browse files
Options
Downloads
Patches
Plain Diff
Prevent crash after updating thunar if old thunar deamon is still running
parent
ba48c5ba
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
thunar/main.c
+77
-0
77 additions, 0 deletions
thunar/main.c
with
77 additions
and
0 deletions
thunar/main.c
+
77
−
0
View file @
ad8663a4
...
...
@@ -45,6 +45,73 @@
static
void
thunar_terminate_running_thunar
(
void
)
{
GDBusConnection
*
connection
;
GDBusProxy
*
proxy
;
GError
*
error
;
error
=
NULL
;
connection
=
g_bus_get_sync
(
G_BUS_TYPE_SESSION
,
NULL
,
&
error
);
g_assert_no_error
(
error
);
proxy
=
g_dbus_proxy_new_sync
(
connection
,
G_DBUS_PROXY_FLAGS_NONE
,
NULL
,
"org.xfce.Thunar"
,
/* bus name */
"/org/xfce/FileManager"
,
/* object path */
"org.xfce.Thunar"
,
/* interface name */
NULL
,
&
error
);
g_assert_no_error
(
error
);
g_dbus_proxy_call_sync
(
proxy
,
"Terminate"
,
/* method name */
NULL
,
G_DBUS_CALL_FLAGS_NONE
,
-
1
,
NULL
,
&
error
);
g_assert_no_error
(
error
);
g_object_unref
(
proxy
);
g_object_unref
(
connection
);
}
static
void
thunar_dialog_ask_terminate_old_daemon_activate
(
GtkApplication
*
app
,
gpointer
user_data
)
{
GtkWidget
*
window
;
GtkWidget
*
dialog
;
gint
result
;
window
=
gtk_application_window_new
(
app
);
dialog
=
gtk_message_dialog_new
(
GTK_WINDOW
(
window
),
GTK_DIALOG_DESTROY_WITH_PARENT
,
GTK_MESSAGE_QUESTION
,
GTK_BUTTONS_YES_NO
,
_
(
"Thunar cannot be launched because an older instance of thunar is still running.
\n
"
"Would you like to terminate the old thunar instance and start this instance?
\n\n
"
"Before accepting please make sure there are no pending operations (e.g. file copying) as terminating them may leave your files corrupted."
));
result
=
gtk_dialog_run
(
GTK_DIALOG
(
dialog
));
if
(
result
==
GTK_RESPONSE_YES
)
thunar_terminate_running_thunar
();
gtk_widget_destroy
(
window
);
g_application_quit
(
G_APPLICATION
(
app
));
}
static
void
thunar_dialog_ask_terminate_old_daemon
(
void
)
{
GtkApplication
*
app
;
app
=
gtk_application_new
(
"terminate.old.thunar.daemon"
,
G_APPLICATION_FLAGS_NONE
);
g_signal_connect
(
app
,
"activate"
,
G_CALLBACK
(
thunar_dialog_ask_terminate_old_daemon_activate
),
NULL
);
g_application_run
(
G_APPLICATION
(
app
),
0
,
0
);
g_object_unref
(
app
);
}
int
main
(
int
argc
,
char
**
argv
)
{
...
...
@@ -93,6 +160,16 @@ main (int argc, char **argv)
/* use the Thunar icon as default for new windows */
gtk_window_set_default_icon_name
(
"Thunar"
);
/* Workaround to bypass "silent fail" if new thunar version is installed while an old version still runs as daemon */
/* FIXME: "g_application_register" and the following logic can be removed as soon as g_application/gdbus provides a way to prevent this error */
g_application_register
(
G_APPLICATION
(
application
),
NULL
,
&
error
);
if
(
error
!=
NULL
)
{
if
(
error
->
code
==
G_DBUS_ERROR_UNKNOWN_METHOD
&&
strstr
(
error
->
message
,
"GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: Method
\"
DescribeAll
\"
with signature
\"\"
on interface
\"
org.gtk.Actions"
))
thunar_dialog_ask_terminate_old_daemon
();
g_error_free
(
error
);
}
/* do further processing inside gapplication */
g_application_run
(
G_APPLICATION
(
application
),
argc
,
argv
);
...
...
This diff is collapsed.
Click to expand it.
Administrator
@root
mentioned in commit
681cb9d5
·
5 years ago
mentioned in commit
681cb9d5
mentioned in commit 681cb9d5a96710cb24fb023dd273439a8493f88b
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment