Explorar el Código

Unlock styles in an idiomatic way.

Hugh Gao hace 10 años
padre
commit
427281679d
Se han modificado 1 ficheros con 1 adiciones y 1 borrados
  1. 1 1
      xmlStyle.go

+ 1 - 1
xmlStyle.go

@@ -288,6 +288,7 @@ func (styles *xlsxStyleSheet) newNumFmt(formatCode string) xlsxNumFmt {
 	// The user define NumFmtId. The one less than 164 in built in.
 	// The user define NumFmtId. The one less than 164 in built in.
 	numFmtId = builtinNumFmtsCount + 1
 	numFmtId = builtinNumFmtsCount + 1
 	styles.lock.Lock()
 	styles.lock.Lock()
+	defer styles.lock.Unlock()
 	for {
 	for {
 		// get a unused NumFmtId
 		// get a unused NumFmtId
 		if _, ok = styles.numFmtRefTable[numFmtId]; ok {
 		if _, ok = styles.numFmtRefTable[numFmtId]; ok {
@@ -297,7 +298,6 @@ func (styles *xlsxStyleSheet) newNumFmt(formatCode string) xlsxNumFmt {
 			break
 			break
 		}
 		}
 	}
 	}
-	styles.lock.Unlock()
 	return xlsxNumFmt{NumFmtId: numFmtId, FormatCode: formatCode}
 	return xlsxNumFmt{NumFmtId: numFmtId, FormatCode: formatCode}
 }
 }