@@ -45,11 +45,13 @@ struct host
4545 unsigned int client_edge : 1 ;
4646 unsigned int use_set_rect : 1 ;
4747 unsigned int use_back_colour : 1 ;
48+ unsigned int defer_release : 1 ;
4849 PARAFORMAT2 para_fmt ;
4950 DWORD props , scrollbars , event_mask ;
5051 RECT client_rect , set_rect ;
5152 COLORREF back_colour ;
5253 WCHAR password_char ;
54+ unsigned int notify_level ;
5355};
5456
5557static const ITextHost2Vtbl textHostVtbl ;
@@ -119,6 +121,8 @@ struct host *host_create( HWND hwnd, CREATESTRUCTW *cs, BOOL emulate_10 )
119121 GetClientRect ( hwnd , & texthost -> client_rect );
120122 texthost -> use_back_colour = 0 ;
121123 texthost -> password_char = (texthost -> props & TXTBIT_USEPASSWORD ) ? '*' : 0 ;
124+ texthost -> defer_release = 0 ;
125+ texthost -> notify_level = 0 ;
122126
123127 return texthost ;
124128}
@@ -1361,12 +1365,24 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam,
13611365
13621366 if ((((host -> event_mask & ENM_KEYEVENTS ) && msg >= WM_KEYFIRST && msg <= WM_KEYLAST ) ||
13631367 ((host -> event_mask & ENM_MOUSEEVENTS ) && msg >= WM_MOUSEFIRST && msg <= WM_MOUSELAST ) ||
1364- ((host -> event_mask & ENM_SCROLLEVENTS ) && msg >= WM_HSCROLL && msg <= WM_VSCROLL )) &&
1365- send_msg_filter ( host , msg , & wparam , & lparam ))
1368+ ((host -> event_mask & ENM_SCROLLEVENTS ) && msg >= WM_HSCROLL && msg <= WM_VSCROLL )))
13661369 {
1367- TRACE ( "exit (filtered) hwnd %p msg %04x (%s) %lx %lx -> %lu\n" ,
1368- hwnd , msg , get_msg_name (msg ), wparam , lparam , res );
1369- return res ;
1370+ host -> notify_level ++ ;
1371+ res = send_msg_filter ( host , msg , & wparam , & lparam );
1372+ if (!-- host -> notify_level && host -> defer_release )
1373+ {
1374+ TRACE ( "exit (filtered deferred release) hwnd %p msg %04x (%s) %lx %lx -> 0\n" ,
1375+ hwnd , msg , get_msg_name (msg ), wparam , lparam );
1376+ ITextHost2_Release ( & host -> ITextHost_iface );
1377+ return 0 ;
1378+ }
1379+
1380+ if (res )
1381+ {
1382+ TRACE ( "exit (filtered %lu) hwnd %p msg %04x (%s) %lx %lx -> 0\n" ,
1383+ res , hwnd , msg , get_msg_name (msg ), wparam , lparam );
1384+ return 0 ;
1385+ }
13701386 }
13711387
13721388 switch (msg )
@@ -1402,7 +1418,8 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam,
14021418 break ;
14031419 }
14041420 case WM_DESTROY :
1405- ITextHost2_Release ( & host -> ITextHost_iface );
1421+ if (!host -> notify_level ) ITextHost2_Release ( & host -> ITextHost_iface );
1422+ else host -> defer_release = 1 ;
14061423 return 0 ;
14071424
14081425 case WM_ERASEBKGND :
0 commit comments