only increase refcount for surface create for window and menu created by the server

This commit is contained in:
Vincent Wei
2020-03-22 22:52:57 +08:00
parent f196a67afe
commit bbd1776911
2 changed files with 7 additions and 1 deletions

View File

@@ -815,6 +815,9 @@ static int srvAllocZOrderNode (int cli, HWND hwnd, HWND main_win,
if (cli == 0) {
PMAINWIN pwin = (PMAINWIN)hwnd;
surf = pwin->surf;
// prevent to free this surface when deleting memdc for znode.
surf->refcount++;
}
else if (fd >= 0) {
surf = GAL_AttachSharedRGBSurface (fd, surf_size, surf_flags, TRUE);
@@ -827,6 +830,7 @@ static int srvAllocZOrderNode (int cli, HWND hwnd, HWND main_win,
if (surf) {
memdc = CreateMemDCFromSurface (surf);
_WRN_PRINTF ("surface (%p) refcount: %d\n", surf, surf->refcount);
if (memdc == HDC_INVALID) {
if (cli > 0) {
GAL_FreeSurface (surf);
@@ -961,7 +965,7 @@ static int srvMoveWindow (int cli, int idx_znode, const RECT* rcWin,
if (cli == 0) {
PMAINWIN pwin = (PMAINWIN)hwnd;
surf = pwin->surf;
// increase refcount for not freed by DeleteMemDC in dskMoveWindow.
// prevent to free this surface when deleting memdc for znode.
surf->refcount++;
}
else {

View File

@@ -1570,6 +1570,8 @@ static int srvStartTrackPopupMenu (int cli, const RECT* rc, HWND ptmi,
GAL_Surface* surf;
if (cli == 0) {
surf = GetSurfaceFromDC (((PTRACKMENUINFO)ptmi)->dc);
// prevent to free this surface when deleting memdc for znode.
surf->refcount++;
}
else if (fd >= 0) {
surf = GAL_AttachSharedRGBSurface (fd, surf_size, surf_flags, TRUE);