Skip to content

Commit

Permalink
Fix #162: Cannot symlink file if two geeqie instances are running
Browse files Browse the repository at this point in the history
#162

Do not permit a second instance of Geeqie to be started.

There is only one geeqierc.xml file - it is not sensible to allow more
than one instance to be run.

File/New Window can be used instead.
  • Loading branch information
caclark committed Mar 29, 2018
1 parent 7f5ac74 commit 6902246
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,7 @@ gint main(gint argc, gchar *argv[])
CollectionData *first_collection = NULL;
gchar *buf;
CollectionData *cd = NULL;
gchar *app_lock;

#ifdef HAVE_GTHREAD
#if !GLIB_CHECK_VERSION(2,32,0)
Expand Down Expand Up @@ -857,6 +858,16 @@ gint main(gint argc, gchar *argv[])
DEBUG_1("%s main: parse_command_line", get_exec_time());
parse_command_line(argc, argv);

/* If Geeqie is already running, prevent a second instance
* from being started
*/
app_lock = g_build_filename(get_rc_dir(), ".command", NULL);
if (remote_server_exists(app_lock))
{
_exit(0);
}
g_free(app_lock);

DEBUG_1("%s main: mkdir_if_not_exists", get_exec_time());
/* these functions don't depend on config file */
mkdir_if_not_exists(get_rc_dir());
Expand Down
2 changes: 1 addition & 1 deletion src/remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ static gboolean remote_server_read_cb(GIOChannel *source, GIOCondition condition
return TRUE;
}

static gboolean remote_server_exists(const gchar *path)
gboolean remote_server_exists(const gchar *path)
{
RemoteConnection *rc;

Expand Down
1 change: 1 addition & 0 deletions src/remote.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ void remote_control(const gchar *arg_exec, GList *remote_list, const gchar *path
GList *cmd_list, GList *collection_list);

RemoteConnection *remote_server_init(gchar *path, CollectionData *command_collection);
gboolean remote_server_exists(const gchar *path);


#endif
Expand Down

0 comments on commit 6902246

Please sign in to comment.