Skip to content

Commit

Permalink
fix: fix memory leak in skeleton manager and image cropper
Browse files Browse the repository at this point in the history
  • Loading branch information
wzhudev committed Feb 7, 2025
1 parent ed4aea2 commit bf7772e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
10 changes: 5 additions & 5 deletions packages/drawing-ui/src/controllers/image-cropper.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { MessageType } from '@univerjs/design';
import { getDrawingShapeKeyByDrawingSearch, IDrawingManagerService, SetDrawingSelectedOperation } from '@univerjs/drawing';
import { CURSOR_TYPE, degToRad, Image, IRenderManagerService, precisionTo, Vector2 } from '@univerjs/engine-render';
import { IMessageService } from '@univerjs/ui';
import { filter, switchMap } from 'rxjs';
import { of, switchMap } from 'rxjs';
import { AutoImageCropOperation, CloseImageCropOperation, CropType, OpenImageCropOperation } from '../commands/operations/image-crop.operation';
import { ImageCropperObject } from '../views/crop/image-cropper-object';

Expand Down Expand Up @@ -334,14 +334,14 @@ export class ImageCropperController extends Disposable {
imageCropperObject?.dispose();
})
);
const sheetUnit = this._univerInstanceService

const sheetUnit$ = this._univerInstanceService
.getCurrentTypeOfUnit$<Workbook>(UniverInstanceType.UNIVER_SHEET)
.pipe(
filter((workbook) => Boolean(workbook)),
switchMap((workbook) => workbook!.activeSheet$)
switchMap((workbook) => workbook ? workbook.activeSheet$ : of(null))
);

this.disposeWithMe(sheetUnit.subscribe(() => {
this.disposeWithMe(sheetUnit$.subscribe(() => {
this._commandService.syncExecuteCommand(CloseImageCropOperation.id);
}));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ export class SheetSkeletonManagerService extends Disposable implements IRenderMo
this.disposeWithMe(() => {
this._currentSkeletonBefore$.complete();
this._currentSkeleton$.complete();
this._sheetSkeletonParamStore = new Map();
this._sheetSkService.deleteSkeleton(this._context.unitId, this._sheetId);

this._sheetSkeletonParamStore.forEach((sk) => this.disposeSkeleton(sk.sheetId));
this._sheetSkeletonParamStore.clear();
});

this._initRemoveSheet();
Expand Down

0 comments on commit bf7772e

Please sign in to comment.