Skip to content

Commit

Permalink
Bugfix for listbox master objects on multiple sheets. (#450)
Browse files Browse the repository at this point in the history
* replace ID for extended ID if exists
  • Loading branch information
DnlLrssn authored Jan 31, 2024
1 parent 66102ee commit 3e516bc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
17 changes: 14 additions & 3 deletions session/idmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ func (idm *IDMap) IsDuplicateKey(key string) error {

// Add new key to id map
func (idm *IDMap) Add(key, id string, logEntry *logger.LogEntry) error {
return idm.add(key, id, logEntry, false)
}

// Replace key in id map
func (idm *IDMap) Replace(key, id string, logEntry *logger.LogEntry) error {
return idm.add(key, id, logEntry, true)
}

func (idm *IDMap) add(key, id string, logEntry *logger.LogEntry, overwrite bool) error {
if idm == nil {
return errors.New("IDMap is nil")
}
Expand All @@ -57,9 +66,11 @@ func (idm *IDMap) Add(key, id string, logEntry *logger.LogEntry) error {

idm.newIfNil()

// First check if key already exists
if err := idm.IsDuplicateKey(key); err != nil {
return errors.WithStack(err)
if !overwrite {
// First check if key already exists
if err := idm.IsDuplicateKey(key); err != nil {
return errors.WithStack(err)
}
}

idm.m.Store(key, id)
Expand Down
6 changes: 2 additions & 4 deletions session/objecthandling.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,8 @@ func DefaultSetObjectDataAndEvents(sessionState *State, actionState *action.Stat
properties := obj.Properties()
if properties != nil && properties.ExtendsId != "" && properties.Info != nil && properties.Info.Type == "listbox" {
// Special handling of objects wrapping listbox objects due to changes for listboxes belonging to filterpanes
if err := sessionState.IDMap.IsDuplicateKey(properties.ExtendsId); err == nil {
if err := sessionState.IDMap.Add(properties.ExtendsId, obj.ID, sessionState.LogEntry); err != nil {
sessionState.LogEntry.LogDetail(logger.WarningLevel, fmt.Sprintf("error adding id<%s> to IDMap", properties.ExtendsId), err.Error())
}
if err := sessionState.IDMap.Replace(properties.ExtendsId, obj.ID, sessionState.LogEntry); err != nil {
sessionState.LogEntry.LogDetail(logger.WarningLevel, fmt.Sprintf("error adding id<%s> to IDMap", properties.ExtendsId), err.Error())
}
}

Expand Down

0 comments on commit 3e516bc

Please sign in to comment.