|  | @@ -379,9 +379,12 @@ void la_StepPropPack(laPropPack *pp){
 | 
											
												
													
														|  |                  continue;
 |  |                  continue;
 | 
											
												
													
														|  |              }else{
 |  |              }else{
 | 
											
												
													
														|  |                  void *inst;
 |  |                  void *inst;
 | 
											
												
													
														|  | -                inst = laGetActiveInstanceStrict(ps->p, UseInstance);
 |  | 
 | 
											
												
													
														|  | -                if (!inst) inst = laGetInstance(ps->p, UseInstance, 0);
 |  | 
 | 
											
												
													
														|  | -                UseInstance = inst;
 |  | 
 | 
											
												
													
														|  | 
 |  | +                if(((laSubProp*)ps->p)->IsDetached){ UseInstance = ((laSubProp*)ps->p)->Detached; }
 | 
											
												
													
														|  | 
 |  | +                else{
 | 
											
												
													
														|  | 
 |  | +                    inst = laGetActiveInstanceStrict(ps->p, UseInstance);
 | 
											
												
													
														|  | 
 |  | +                    if (!inst) inst = laGetInstance(ps->p, UseInstance, 0);
 | 
											
												
													
														|  | 
 |  | +                    UseInstance = inst;
 | 
											
												
													
														|  | 
 |  | +                }
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |              if (!ps->pNext){
 |  |              if (!ps->pNext){
 | 
											
												
													
														|  |                  pp->EndInstance = UseInstance;
 |  |                  pp->EndInstance = UseInstance;
 | 
											
										
											
												
													
														|  | @@ -553,6 +556,37 @@ void laThreadNotifyUsers(char *Path){
 | 
											
												
													
														|  |      lstAppendItem(&MAIN.ThreadNotifiers, tn);
 |  |      lstAppendItem(&MAIN.ThreadNotifiers, tn);
 | 
											
												
													
														|  |      //laSpinUnlock(&MAIN.csNotifier);
 |  |      //laSpinUnlock(&MAIN.csNotifier);
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  | 
 |  | +void la_PanelResetDetachedReference(laPanel*p,void*Old,void*New){
 | 
											
												
													
														|  | 
 |  | +    for(laSubProp* sp=p->PropLinkContainer->Props.pFirst;sp;sp=sp->Base.Item.pNext){
 | 
											
												
													
														|  | 
 |  | +        if(sp->Base.PropertyType!=LA_PROP_SUB) continue;
 | 
											
												
													
														|  | 
 |  | +        if(sp->Detached == Old){ memAssignRef(sp, &sp->Detached, New); }
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +    for(laPanel* sp=p->SubPanels.pFirst;sp;sp=sp->Item.pNext){
 | 
											
												
													
														|  | 
 |  | +        la_PanelResetDetachedReference(sp,Old,New);
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  | 
 |  | +void la_NotifyDetachedRecursive(laBlock* b, void* Old, void* New){
 | 
											
												
													
														|  | 
 |  | +    if(b->B1){ la_NotifyDetachedRecursive(b->B1,Old,New);la_NotifyDetachedRecursive(b->B2,Old,New); return; }
 | 
											
												
													
														|  | 
 |  | +    for(laPanel* p=b->Panels.pFirst;p;p=p->Item.pNext){
 | 
											
												
													
														|  | 
 |  | +        la_PanelResetDetachedReference(p,Old,New);
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  | 
 |  | +void laNotifyDetached(void* OldInstance, void* NewInstance){
 | 
											
												
													
														|  | 
 |  | +    for(laWindow* w=MAIN.Windows.pFirst;w;w=w->Item.pNext){
 | 
											
												
													
														|  | 
 |  | +        for(laLayout* l=w->Layouts.pFirst;l;l=l->Item.pNext){
 | 
											
												
													
														|  | 
 |  | +            la_NotifyDetachedRecursive(l->FirstBlock,OldInstance,NewInstance);
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        for(laPanel* p=w->Panels.pFirst;p;p=p->Item.pNext){
 | 
											
												
													
														|  | 
 |  | +            la_PanelResetDetachedReference(p,OldInstance,NewInstance);
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  | 
 |  | +void laDetachedTrySet(char* prop_identifier,void* NewInstance){
 | 
											
												
													
														|  | 
 |  | +    laPanel* p=MAIN.CurrentPanel; for(laSubProp* sp=p->PropLinkContainer->Props.pFirst;sp;sp=sp->Base.Item.pNext){
 | 
											
												
													
														|  | 
 |  | +        if(sp->Base.PropertyType!=LA_PROP_SUB){ continue; }
 | 
											
												
													
														|  | 
 |  | +        if(strSame(sp->Base.Identifier,prop_identifier)){ memAssignRef(sp,&sp->Detached,NewInstance); }
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  void la_SetPropMathcerContext(laPanel *p){
 |  |  void la_SetPropMathcerContext(laPanel *p){
 | 
											
												
													
														|  |      MAIN.PropMatcherContextP = p;
 |  |      MAIN.PropMatcherContextP = p;
 | 
											
										
											
												
													
														|  | @@ -881,6 +915,7 @@ laProp *la_MakeDetachedProp(laPanel* p, const char *From, const char *Rename){
 | 
											
												
													
														|  |          break;
 |  |          break;
 | 
											
												
													
														|  |      case LA_PROP_SUB:
 |  |      case LA_PROP_SUB:
 | 
											
												
													
														|  |          sp=np; sp->GetCategory=((laSubProp*)np)->GetCategory;
 |  |          sp=np; sp->GetCategory=((laSubProp*)np)->GetCategory;
 | 
											
												
													
														|  | 
 |  | +        sp->IsDetached=1;
 | 
											
												
													
														|  |          break;
 |  |          break;
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |      lstAppendItem(&p->PropLinkContainer->Props, np);
 |  |      lstAppendItem(&p->PropLinkContainer->Props, np);
 | 
											
										
											
												
													
														|  | @@ -4141,6 +4176,7 @@ int la_GenerateListDifferences(laDBInst* dbi, laDBSubProp* dbp, laPropPack* pp,
 | 
											
												
													
														|  |      inst = laGetInstance(p, pp->LastPs->UseInstance, &pi);
 |  |      inst = laGetInstance(p, pp->LastPs->UseInstance, &pi);
 | 
											
												
													
														|  |      pp->EndInstance = inst;
 |  |      pp->EndInstance = inst;
 | 
											
												
													
														|  |      while (inst){
 |  |      while (inst){
 | 
											
												
													
														|  | 
 |  | +        if(p->UDFIsSingle){ memTake(inst); /* For single must take or it will be freed. */ }
 | 
											
												
													
														|  |          lstAppendPointer(&New, inst);
 |  |          lstAppendPointer(&New, inst);
 | 
											
												
													
														|  |          inst = laGetNextInstance(p, inst, &pi);
 |  |          inst = laGetNextInstance(p, inst, &pi);
 | 
											
												
													
														|  |          pp->EndInstance = inst;
 |  |          pp->EndInstance = inst;
 | 
											
										
											
												
													
														|  | @@ -4413,7 +4449,7 @@ void la_UndoListDifferences(laDBSubProp* dsp, laDiffCommandSub* dcs){
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |      for(laDiffCommandInst* dci=dcs->RemovedInst.pFirst;dci;dci=dci->Item.pNext){ if(dcs->Base.p->UDFNoCreate) continue;
 |  |      for(laDiffCommandInst* dci=dcs->RemovedInst.pFirst;dci;dci=dci->Item.pNext){ if(dcs->Base.p->UDFNoCreate) continue;
 | 
											
												
													
														|  |          dci->DBInst->Item.pPrev = dci->OriginalPrev;
 |  |          dci->DBInst->Item.pPrev = dci->OriginalPrev;
 | 
											
												
													
														|  | -        dci->DBInst->Item.pNext = dci->OriginalNext; printf("add removed %x \n", dci->DBInst->OriginalInstance);
 |  | 
 | 
											
												
													
														|  | 
 |  | +        dci->DBInst->Item.pNext = dci->OriginalNext; printf("add removed %s %x \n",dci->DBInst->pc->Identifier, dci->DBInst->OriginalInstance);
 | 
											
												
													
														|  |          void* orig = dci->DBInst->OriginalInstance;
 |  |          void* orig = dci->DBInst->OriginalInstance;
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |      for(laDiffCommandInst* dci=dcs->RemovedInst.pFirst;dci;dci=dci->Item.pNext){ if(dcs->Base.p->UDFNoCreate) continue;
 |  |      for(laDiffCommandInst* dci=dcs->RemovedInst.pFirst;dci;dci=dci->Item.pNext){ if(dcs->Base.p->UDFNoCreate) continue;
 | 
											
										
											
												
													
														|  | @@ -4465,6 +4501,7 @@ laDBProp* la_FindDBProp(laDBInst* dbi, laProp* p){
 | 
											
												
													
														|  |      return 0;
 |  |      return 0;
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +void tnsPrintMaterials();
 | 
											
												
													
														|  |  laDiff* laSwapDBState(int Redo){
 |  |  laDiff* laSwapDBState(int Redo){
 | 
											
												
													
														|  |      laDiff* diff=MAIN.HeadDifference; if(!diff) return 0;
 |  |      laDiff* diff=MAIN.HeadDifference; if(!diff) return 0;
 | 
											
												
													
														|  |      if(Redo){ if(diff==MAIN.Differences.pLast) return 0; }else{ diff=diff->Item.pPrev; if(!diff) return 0; }
 |  |      if(Redo){ if(diff==MAIN.Differences.pLast) return 0; }else{ diff=diff->Item.pPrev; if(!diff) return 0; }
 | 
											
										
											
												
													
														|  | @@ -4501,6 +4538,7 @@ laDiff* laSwapDBState(int Redo){
 | 
											
												
													
														|  |      for(laDiffCommandCustom* dcc=diff->CustomCommands.pFirst;dcc;dcc=dcc->Item.pNext){
 |  |      for(laDiffCommandCustom* dcc=diff->CustomCommands.pFirst;dcc;dcc=dcc->Item.pNext){
 | 
											
												
													
														|  |          if(Redo){ if(dcc->Redo) dcc->Redo(dcc->Data); } else { if(dcc->Undo) dcc->Undo(dcc->Data); }
 |  |          if(Redo){ if(dcc->Redo) dcc->Redo(dcc->Data); } else { if(dcc->Undo) dcc->Undo(dcc->Data); }
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  | 
 |  | +    tnsPrintMaterials();
 | 
											
												
													
														|  |      if(Redo){ MAIN.HeadDifference=diff->Item.pNext; }
 |  |      if(Redo){ MAIN.HeadDifference=diff->Item.pNext; }
 | 
											
												
													
														|  |      else{ MAIN.HeadDifference=diff; }
 |  |      else{ MAIN.HeadDifference=diff; }
 | 
											
												
													
														|  |      return diff;
 |  |      return diff;
 |