denemo-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Denemo-devel] copying the chord directives


From: Richard Shann
Subject: Re: [Denemo-devel] copying the chord directives
Date: Fri, 17 Jul 2009 17:56:19 +0100

On Fri, 2009-07-17 at 08:20 -0500, Jeremiah Benham wrote:
> On Fri, 17 Jul 2009 10:10:38 +0100
> Richard Shann <address@hidden> wrote:
> 
> > Jeremiah,
> > I think you have introduced some bad code
> > 
> > <   thechord->directives = g_list_copy(g);
> > 
> > if you are just adding and deleting notes there is no need to do
> > anything about the directives attached to the chord, they won't be
> > touched.
> > It is those attached to the note you might want to preserve. But even
> > in this case don't copy them, just detach them and re-connect to the
> > new note. 
> > note->directives = NULL
> > detaches a list from note (so that it doesn't get deleted when the
> > note gets deleted) and then you can re-attach it to the new note
> > 
> > newnote->directives = the value of note->directives before you
> > detached it.
> > 
> 
> Yeah. I found the email you mentioned. You recommended doing this:
> 
> GList *g =  ;
> note->directives = NULL;
> delete_note_from_chord(note);
> add_note_to_chord(newnote);
> newnote->directives = g;
> 
> > Is it clear - I sketched it in the earlier mail? 
> I removed any directive copying for the d-PutNoteName because it didn't
> need it. It is but I was deleting all the notes first then putting new
> ones up to replace them. I changed the code and pushed it to git but
> now I realize that I have to copy the directives for each note. I
> deleted the notes first so I did not get the notes being deleted
> tangled up with the newly created ones.
You were right I think to do this,

> 
> Would it be bad to created a GList and append the selected notes
> directives onto it? Then assign it to the newly created notes?
what you need to do is make a list of the pointers (i.e. a list lists)
 list = g_list_append(list, note->directives);
and note->directives = NULL;
as you delete each note.

and then put the directives (ie. the g->data where g=list,
g=g->next ...) back on to successive new notes, finally freeing the list
(but not any data that it contain(s)/(ed)). If there are different
numbers of notes you may have some directives left over, there exist
functions for freeing lists of directives in objops.c IIRC.
Richard



> 
> Jeremiah
> 
> 
> > Richard
> > 
> > 
> > 
> > 
> > _______________________________________________
> > Denemo-devel mailing list
> > address@hidden
> > http://lists.gnu.org/mailman/listinfo/denemo-devel
> 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]