Skip to content

Commit 8c10a4a

Browse files
pengfeixxdeepin-bot[bot]
authored andcommitted
fix: Fix the issue of failing to switch languages
Fixed the issue where adding a language during language switching caused the switch to fail Fix the issue of failing to switch languages pms: BUG-340603
1 parent 1a42296 commit 8c10a4a

1 file changed

Lines changed: 28 additions & 19 deletions

File tree

langselector1/locale.go

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -550,27 +550,36 @@ func (lang *LangSelector) doGenerateLocale(locale string) error {
550550
return err
551551
}
552552

553-
select {
554-
case <-time.NewTimer(10 * time.Minute).C:
555-
return errors.New("wait success signal timed out")
556-
case sig := <-sigChan:
557-
if len(sig.Body) != 2 {
558-
return errSignalBodyInvalid
559-
}
560-
genLocaleOk, ok := sig.Body[0].(bool)
561-
if !ok {
562-
return errSignalBodyInvalid
563-
}
553+
timer := time.NewTimer(10 * time.Minute)
554+
defer timer.Stop()
555+
556+
for {
557+
select {
558+
case <-timer.C:
559+
return errors.New("wait success signal timed out")
560+
case sig := <-sigChan:
561+
if sig.Path != dbus.ObjectPath("/org/deepin/dde/LocaleHelper1") || sig.Name != "org.deepin.dde.LocaleHelper1.Success" {
562+
continue
563+
}
564564

565-
failReason, ok := sig.Body[1].(string)
566-
if !ok {
567-
return errSignalBodyInvalid
568-
}
565+
if len(sig.Body) != 2 {
566+
return errSignalBodyInvalid
567+
}
568+
genLocaleOk, ok := sig.Body[0].(bool)
569+
if !ok {
570+
return errSignalBodyInvalid
571+
}
569572

570-
if genLocaleOk {
571-
return nil
572-
} else {
573-
return errors.New(failReason)
573+
failReason, ok := sig.Body[1].(string)
574+
if !ok {
575+
return errSignalBodyInvalid
576+
}
577+
578+
if genLocaleOk {
579+
return nil
580+
} else {
581+
return errors.New(failReason)
582+
}
574583
}
575584
}
576585
}

0 commit comments

Comments
 (0)