diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c index 98cee743239..335b24489bd 100644 --- a/dlls/riched20/richole.c +++ b/dlls/riched20/richole.c @@ -5257,6 +5257,7 @@ void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize) return; } } + IDataObject_Release(ido); switch (stgm.tymed) { @@ -5264,19 +5265,17 @@ void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize) GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect); pSize->cx = dibsect.dsBm.bmWidth; pSize->cy = dibsect.dsBm.bmHeight; - if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap); break; case TYMED_ENHMF: GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh); pSize->cx = emh.rclBounds.right - emh.rclBounds.left; pSize->cy = emh.rclBounds.bottom - emh.rclBounds.top; - if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile); break; default: FIXME("Unsupported tymed %d\n", stgm.tymed); break; } - IDataObject_Release(ido); + ReleaseStgMedium(&stgm); if (c->editor->nZoomNumerator != 0) { pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator); @@ -5294,6 +5293,7 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run, BOOL selected) HDC hMemDC; SIZE sz; BOOL has_size; + HBITMAP old_bm; assert(run->nFlags & MERF_GRAPHICS); assert(run->ole_obj); @@ -5319,12 +5319,14 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run, BOOL selected) return; } } + IDataObject_Release(ido); + switch (stgm.tymed) { case TYMED_GDI: GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect); hMemDC = CreateCompatibleDC(c->hDC); - SelectObject(hMemDC, stgm.u.hBitmap); + old_bm = SelectObject(hMemDC, stgm.u.hBitmap); if (has_size) { convert_sizel(c, &run->ole_obj->sizel, &sz); @@ -5347,8 +5349,8 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run, BOOL selected) hMemDC, 0, 0, dibsect.dsBm.bmWidth, dibsect.dsBm.bmHeight, SRCCOPY); } + SelectObject(hMemDC, old_bm); DeleteDC(hMemDC); - if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap); break; case TYMED_ENHMF: GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh); @@ -5374,16 +5376,16 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run, BOOL selected) rc.bottom = y; PlayEnhMetaFile(c->hDC, stgm.u.hEnhMetaFile, &rc); } - if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile); break; default: FIXME("Unsupported tymed %d\n", stgm.tymed); selected = FALSE; break; } + ReleaseStgMedium(&stgm); + if (selected && !c->editor->bHideSelection) PatBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy, DSTINVERT); - IDataObject_Release(ido); } void ME_DeleteReObject(REOBJECT* reo)