From b7fece51736977e7d84aca30ecce7f6b3a1251f2 Mon Sep 17 00:00:00 2001 From: xuri Date: Tue, 6 Jul 2021 00:31:04 +0800 Subject: Support concurrency add picture --- drawing.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'drawing.go') diff --git a/drawing.go b/drawing.go index 181bb43..86d5ca6 100644 --- a/drawing.go +++ b/drawing.go @@ -1173,8 +1173,13 @@ func (f *File) drawingParser(path string) (*xlsxWsDr, int) { } f.Drawings.Store(path, &content) } - wsDr, _ := f.Drawings.Load(path) - return wsDr.(*xlsxWsDr), len(wsDr.(*xlsxWsDr).OneCellAnchor) + len(wsDr.(*xlsxWsDr).TwoCellAnchor) + 2 + var wsDr *xlsxWsDr + if drawing, ok := f.Drawings.Load(path); ok && drawing != nil { + wsDr = drawing.(*xlsxWsDr) + } + wsDr.Lock() + defer wsDr.Unlock() + return wsDr, len(wsDr.OneCellAnchor) + len(wsDr.TwoCellAnchor) + 2 } // addDrawingChart provides a function to add chart graphic frame by given -- cgit v1.2.1