*/}}
1
0
فهرست منبع

Experimental fix for user interlink

Should stop using data block no matter instances are there or not.

(seems to be correct)
ChengduLittleA 10 ماه پیش
والد
کامیت
e2816aa32f
6فایلهای تغییر یافته به همراه33 افزوده شده و 10 حذف شده
  1. 9 0
      la_data.c
  2. 1 0
      la_data.h
  3. 13 4
      la_kernel.c
  4. 1 1
      la_util.c
  5. 7 3
      resources/la_operators.c
  6. 2 2
      resources/la_properties.c

+ 9 - 0
la_data.c

@@ -137,6 +137,15 @@ void laDataBlockNoLongerExists(void *HyperUserMem, laListHandle* UserList){
         memFree(iul);
     }
 }
+void la_PrintUserList(void* HyperUserMem){
+    laItemUserLinker* iul, * next_iul; laItemUserLinkerLocal* iull; int local;
+    if (!HyperUserMem) return;
+    laListHandle* users = laGetUserList(HyperUserMem, 0, &local); if (!users) return;
+    for (iul = users->pFirst; iul; iul = next_iul) {
+        next_iul = iul->Pointer.pNext;
+        printf("p %x  which %s add %x\n", iul->Pointer.p, iul->Which ? iul->Which->Identifier : "-", iul->Additional);
+    }
+}
 
 //laProp* la_GetGeneralPropFromPath(laProp* General, const char * Path) {
 //	laProp* p;

+ 1 - 0
la_data.h

@@ -845,6 +845,7 @@ void la_GetPropPackPath(laPropPack *pp, char *result);
 laItemUserLinker *laUseDataBlock(void* HyperUserMem, laProp *Which, unsigned int FrameDistinguish, void *User, laUserRemoveFunc Remover, int ForceRecalc);
 void laStopUsingDataBlock(void* HyperUserMem, laProp *prop, laPanel *p);
 void laDataBlockNoLongerExists(void *HyperUserMem, laListHandle* UserList);
+void la_PrintUserList(void* HyperUserMem);
 
 void laThrowToTrashBin(void* Data, char *ContainerString);
 

+ 13 - 4
la_kernel.c

@@ -423,12 +423,21 @@ void la_DestroyWindow(laWindow *wnd){
 
     strSafeDestroy(&wnd->Title);
 
+    la_PrintUserList(wnd);
+    printf("----\n");
+
     while (p = lstPopItem(&wnd->Panels)){ laDestroySinglePanel(p,1); }
     while (l = lstPopItem(&wnd->Layouts)){
         laDestroyBlocksRecursive(l->FirstBlock);
+        la_PrintUserList(l);
+        printf("%x %s\n", l, l->ID->Ptr);
         strSafeDestroy(&l->ID);
         memFree(l);
+        la_PrintUserList(wnd);
+        printf("----\n");
     }
+    printf("----\n%x\n",wnd);
+    la_PrintUserList(wnd);
     la_DestroySystemWindow(wnd);
     lstRemoveItem(&MAIN.Windows, wnd);
 
@@ -2297,7 +2306,7 @@ int laStartWindow(laWindow *w){
     MAIN.CurrentWindow = w;
     if(!w->CurrentLayout){
         if(!w->Layouts.pFirst){laDesignLayout(w, "Empty Layout");}
-        w->CurrentLayout=w->Layouts.pFirst;
+        memAssignRef(w, &w->CurrentLayout, w->Layouts.pFirst);
     }
     laRedrawCurrentWindow();
     laInvokeUi(0, "LA_window_operator", 0, w, 0, 0);
@@ -2348,11 +2357,11 @@ void laDestroyLayout(laWindow *w, laLayout* l){
     if((!l->Item.pPrev) && (!l->Item.pNext)) return;
     laDestroyBlocksRecursive(l->FirstBlock);
     strSafeDestroy(&l->ID);
-    if(w->CurrentLayout==l){ w->CurrentLayout=l->Item.pPrev?l->Item.pPrev:l->Item.pNext; }
+    if(w->CurrentLayout==l){ memAssignRef(w, &w->CurrentLayout, l->Item.pPrev?l->Item.pPrev:l->Item.pNext); }
     lstRemoveItem(&w->Layouts,l); memFree(l);
 }
 laLayout *laDesignLayout(laWindow *w, char *Title){
-    laLayout *l = memAcquireHyper(sizeof(laLayout));
+    laLayout *l = memAcquire(sizeof(laLayout));
 
     l->FirstBlock = memAcquire(sizeof(laBlock));
     la_AssignBlockPP(l->FirstBlock);
@@ -2360,7 +2369,7 @@ laLayout *laDesignLayout(laWindow *w, char *Title){
     lstAppendItem(&w->Layouts, l);
     strSafeSet(&l->ID, Title);
 
-    w->CurrentLayout = l;
+    memAssignRef(w, &w->CurrentLayout, l);
     laRenameWindow(w, Title);
 
     return l;

+ 1 - 1
la_util.c

@@ -1210,7 +1210,7 @@ void *memStaticDestroy(laStaticMemoryPool *smp){
 }
 
 void la_ReferencedBlockDeleted(void* This, laItemUserLinker* iul){
-    void** user=iul->Pointer.p; if(*user==This){ (*user)=0; laStopUsingDataBlock(iul->Additional, 0, This); }
+    void** user=iul->Pointer.p; if(*user==This){ (*user)=0; } laStopUsingDataBlock(iul->Additional, 0, This); // <<< should always remove.
 }
 void la_ReferrerDeleted(void* This, laItemUserLinker* iul){
     void* instance=iul->Pointer.p; if(instance!=This){ laStopUsingDataBlock(instance, 0, This); }

+ 7 - 3
resources/la_operators.c

@@ -1176,7 +1176,9 @@ int OPINV_NewWindow(laOperator* a, laEvent* e){
 
     if (l && !strSame(strGetArgumentString(a->ExtraInstructionsP, "clean"), "true")){
         laLayout* nextl=l->Item.pPrev?l->Item.pPrev:l->Item.pNext;
-        w->CurrentLayout=nextl; lstRemoveItem(&w->Layouts, l); lstAppendItem(&nw->Layouts, l); nw->CurrentLayout=l;
+        memAssignRef(w, &w->CurrentLayout, nextl);
+        lstRemoveItem(&w->Layouts, l); lstAppendItem(&nw->Layouts, l);
+        memAssignRef(nw, &nw->CurrentLayout, l);
         laRenameWindow(nw, l->ID->Ptr);
         laRenameWindow(w, w->CurrentLayout->ID->Ptr);
     }else{
@@ -1435,8 +1437,10 @@ int OPINV_SwitchLayout(laOperator *a, laEvent *e){
         return LA_RUNNING;
     }
 
-    if (strSame(strGetArgumentString(a->ExtraInstructionsP, "reverse"), "true")) w->CurrentLayout = w->CurrentLayout->Item.pPrev ? w->CurrentLayout->Item.pPrev : w->Layouts.pLast;
-    else w->CurrentLayout = w->CurrentLayout->Item.pNext ? w->CurrentLayout->Item.pNext : w->Layouts.pFirst;
+    laLayout* newlayout;
+    if (strSame(strGetArgumentString(a->ExtraInstructionsP, "reverse"), "true")) newlayout = w->CurrentLayout->Item.pPrev ? w->CurrentLayout->Item.pPrev : w->Layouts.pLast;
+    else newlayout = w->CurrentLayout->Item.pNext ? w->CurrentLayout->Item.pNext : w->Layouts.pFirst;
+    memAssignRef(w, &w->CurrentLayout, newlayout);
 
     laRenameWindow(w, w->CurrentLayout->ID->Ptr);
 

+ 2 - 2
resources/la_properties.c

@@ -367,7 +367,7 @@ void laset_LayoutTitle(laLayout *l, char *content){
 //}
 void laset_WindowActiveLayout(laWindow *w, laLayout *l, int UNUSED_State){
     la_StopAllOperators();
-    w->CurrentLayout = l;
+    memAssignRef(w, &w->CurrentLayout, l);
     if(!w->win){return;}
     laRenameWindow(w, l->ID->Ptr);
     laRedrawCurrentWindow();
@@ -1463,7 +1463,7 @@ void la_RegisterInternalProps(){
             laAddOperatorProperty(p, "maximize", "Maximize", "Maximize the block", "LA_block_maximize", 0,0);
         }
 
-        p = laAddPropertyContainer("ui_layout", "Layout Node", "Property Container For Single Layout", 0,laui_LayoutListItem, sizeof(laLayout), 0,0,2);{
+        p = laAddPropertyContainer("ui_layout", "Layout Node", "Property Container For Single Layout", 0,laui_LayoutListItem, sizeof(laLayout), 0,0,1);{
             laAddStringProperty(p, "title", "Title", "The Title/Name Of A Panel", 0,0,0,0,1, offsetof(laLayout, ID), 0,0,laset_LayoutTitle,0,LA_AS_IDENTIFIER);
             _LA_PROP_BLOCK = laAddSubGroup(p, "root_block", "Root Block", "Root Block For Panel Docking", "ui_block",0,0,0,offsetof(laLayout, FirstBlock), 0,0,0,0,0,0,0,LA_UDF_SINGLE);
             la_UDFAppendSharedTypePointer("_LA_PROP_BLOCK", _LA_PROP_BLOCK);