Changeset 4bad0a8038418a359af306aa505568561f0fc0ac

Show
Ignore:
Timestamp:
09/18/10 19:30:36 (3 years ago)
Author:
Nedko Arnaudov <nedko@…>
Children:
7217c4f3d3ca45ca7950c5337d0f31e119484fed
Parents:
bb7abc0783e1e30e421daabbd1272084c4cadde9
git-committer:
Nedko Arnaudov <nedko@arnaudov.name> / 2010-09-18T19:30:36Z+0300
Message:

Properly handle saveas of automatic studios. Fix for #108

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • daemon/cmd_save_studio.c

    r09cb302 r4bad0a8  
    202202  struct stat st; 
    203203  struct ladish_write_context save_context; 
     204  bool renaming; 
    204205 
    205206  ASSERT(cmd_ptr->command.state == LADISH_COMMAND_STATE_PENDING); 
     
    225226    goto exit; 
    226227  } 
     228 
     229  /* whether save will initiate a rename */ 
     230  renaming = strcmp(cmd_ptr->studio_name, g_studio.name) != 0; 
    227231 
    228232  if (g_studio.filename == NULL) 
     
    239243    old_filename = filename; 
    240244  } 
    241   else if (strcmp(cmd_ptr->studio_name, g_studio.name) == 0) 
    242   { 
    243     /* saving renamed studio */ 
     245  else if (!renaming) 
     246  { 
     247    /* saving already renamed studio */ 
    244248    old_filename = g_studio.filename; 
    245249    g_studio.filename = filename; 
     
    407411  ret = true; 
    408412 
    409   if (old_filename == g_studio.filename && strcmp(g_studio.name, cmd_ptr->studio_name) != 0) 
     413  if (renaming) 
    410414  { 
    411415    free(g_studio.name); 
    412416    g_studio.name = cmd_ptr->studio_name; 
    413     cmd_ptr->studio_name = NULL; 
    414     ladish_studio_emit_renamed(); 
     417    cmd_ptr->studio_name = NULL; /* mark that descructor does not need to free the new name buffer */ 
     418    ladish_studio_emit_renamed(); /* uses g_studio.name */ 
    415419  } 
    416420