Skip to content

Commit

Permalink
* Fixed mixed history when using GetData() due to shallow copy.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pulover committed Oct 1, 2020
1 parent a71b3c1 commit ed62f1f
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions Class_LV_Rows.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ Class LV_Rows extends LV_Rows.LV_EX
Else If (this.hArray.HasKey(NewData))
{
this.hArray[Hwnd].GroupsArray := this.hArray[NewData].GroupsArray.Clone()
, this.hArray[Hwnd].Slot := this.hArray[NewData].Slot.Clone()
, this.hArray[Hwnd].Slot := this.DeepClone(this.hArray[NewData].Slot)
, this.hArray[Hwnd].ActiveSlot := this.hArray[NewData].ActiveSlot
, this.Load()
}
Expand Down Expand Up @@ -243,7 +243,7 @@ Class LV_Rows extends LV_Rows.LV_EX
Else If (this.hArray.HasKey(NewData))
{
this.hArray[Hwnd].GroupsArray := this.hArray[NewData].GroupsArray.Clone()
, this.hArray[Hwnd].Slot := this.hArray[NewData].Slot.Clone()
, this.hArray[Hwnd].Slot := this.DeepClone(this.hArray[NewData].Slot)
, this.hArray[Hwnd].ActiveSlot := this.hArray[NewData].ActiveSlot
, this.Load()
}
Expand All @@ -263,7 +263,7 @@ Class LV_Rows extends LV_Rows.LV_EX
If (Hwnd = "")
Hwnd := this.LVHwnd
If (this.hArray.HasKey(Hwnd))
return this.hArray[Hwnd].Clone()
return this.DeepClone(this.hArray[Hwnd])
}
;=======================================================================================
; Function: Handle.SetData()
Expand Down Expand Up @@ -294,7 +294,7 @@ Class LV_Rows extends LV_Rows.LV_EX
Else If (this.hArray.HasKey(Data))
{
this.hArray[Hwnd].GroupsArray := this.hArray[Data].GroupsArray.Clone()
, this.hArray[Hwnd].Slot := this.hArray[Data].Slot.Clone()
, this.hArray[Hwnd].Slot := this.DeepClone(this.hArray[Data].Slot)
, this.hArray[Hwnd].ActiveSlot := this.hArray[Data].ActiveSlot
, this.Load()
}
Expand Down Expand Up @@ -1276,5 +1276,14 @@ Class LV_Rows extends LV_Rows.LV_EX
StrPut(Str, &WSTR, "UTF-16")
Return &WSTR
}
; ----------------------------------------------------------------------------------------------------------------------
DeepClone(Obj)
{
ObjCopy := Obj.Clone()
For k, v in ObjCopy
If (IsObject(v))
ObjCopy[k] := this.DeepClone(v)
return ObjCopy
}
}
}

0 comments on commit ed62f1f

Please sign in to comment.