Guest User

Untitled

a guest
Oct 21st, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.66 KB | None | 0 0
  1. # HG changeset patch
  2. # User Jerome LAFORGE
  3. # Date 1315058971 -7200
  4. # Node ID 99b48eeeef711990c08473a71541e524ddf7ca3c
  5. # Parent  87da4634b76fb779e054d579989f496c8e78db70
  6. Ensure unique instance when check.if.already.open is set.
  7. Bug #3363754.
  8.  
  9. diff -r 87da4634b76f -r 99b48eeeef71 gtk/SciTEGTK.cxx
  10. --- a/gtk/SciTEGTK.cxx  Sun Aug 21 10:31:44 2011 +0200
  11. +++ b/gtk/SciTEGTK.cxx  Sat Sep 03 16:09:31 2011 +0200
  12. @@ -106,6 +106,7 @@
  13.  }
  14.  
  15.  const char appName[] = "SciTE";
  16. +static char uniqueInstance[MAX_PATH];
  17.  
  18.  static GtkWidget *PWidget(GUI::Window &w) {
  19.     return reinterpret_cast<GtkWidget *>(w.GetID());
  20. @@ -4351,6 +4352,15 @@
  21.     char *pipeFileName = NULL;
  22.     const char *filename;
  23.  
  24. +   sprintf(uniqueInstance,"%s/SciTE.ensure.unique.instance.for.%s", g_get_tmp_dir(), getenv("USER"));
  25. +   int fd = -2;
  26. +   do {
  27. +       if (fd == -1)
  28. +           usleep(50000); // Currently, another process of SciTE is launching. We are waiting for end of its initialisation.
  29. +       fd = open(uniqueInstance, O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
  30. +   } while (fd == -1 && errno == EEXIST);
  31. +   if (fd != -1)
  32. +       close(fd);
  33.     // Find a working pipe in our temporary directory
  34.     while ((filename = g_dir_read_name(dir))) {
  35.         if (g_pattern_match_string(pattern, filename)) {
  36. @@ -4386,6 +4396,7 @@
  37.         // We need to call this since we're not displaying a window
  38.         gdk_notify_startup_complete();
  39.         g_free(pipeFileName);
  40. +       unlink(uniqueInstance);
  41.         return true;
  42.     }
  43.  
  44. @@ -4429,6 +4440,8 @@
  45.     }
  46.  
  47.     CreateUI();
  48. +   if ((props.Get("ipc.director.name").size() == 0) && props.GetInt ("check.if.already.open"))
  49. +       unlink(uniqueInstance);
  50.  
  51.     // Process remaining switches and files
  52.     ProcessCommandLine(args, 1);
Add Comment
Please, Sign In to add comment