[Ttssh2-commit] [8165] TipWinの作成・削除の処理を統一した

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2019年 9月 16日 (月) 00:33:25 JST


Revision: 8165
          https://osdn.net/projects/ttssh2/scm/svn/commits/8165
Author:   yasuhide
Date:     2019-09-16 00:33:25 +0900 (Mon, 16 Sep 2019)
Log Message:
-----------
TipWinの作成・削除の処理を統一した

ウィンドウの破棄とTipWinオブジェクト破棄時の掃除をデストラクタで行う
- CTipWinのCreate,Destroyを隠蔽してnew,deleteで確保、解放するようにした
- TipWinDestroy()でTipWinを解放するようにした

Modified Paths:
--------------
    branches/tootip_classify/teraterm/common/tipwin.cpp
    branches/tootip_classify/teraterm/common/tipwin.h
    branches/tootip_classify/teraterm/teraterm/addsetting.cpp
    branches/tootip_classify/teraterm/teraterm/vtwin.cpp
    branches/tootip_classify/teraterm/teraterm/vtwin.h

-------------- next part --------------
Modified: branches/tootip_classify/teraterm/common/tipwin.cpp
===================================================================
--- branches/tootip_classify/teraterm/common/tipwin.cpp	2019-09-15 15:33:23 UTC (rev 8164)
+++ branches/tootip_classify/teraterm/common/tipwin.cpp	2019-09-15 15:33:25 UTC (rev 8165)
@@ -153,14 +153,6 @@
 
 		case WM_NCHITTEST:
 			return HTTRANSPARENT;
-
-		case WM_DESTROY:
-			if(self->IsExists()) {
-				DeleteObject(self->tWin->tip_font);
-				self->tWin->tip_font = NULL;
-			}
-			break;
-
 		case WM_SETTEXT:
 			{
 				LPCTSTR str = (LPCTSTR) lParam;
@@ -180,11 +172,7 @@
 
 			}
 			break;
-
 		case WM_NCDESTROY:
-			if (self->IsExists()) {
-				free((void *)self->tWin->str);
-				free(self->tWin);
 				/*
 				 * use-after-free\x82ɂ\xE6\x82\xE8Tera Term\x82̓\xAE\x8D삪\x95s\x88\xC0\x92\xE8\x82ƂȂ\xE9\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B
 				 *
@@ -192,7 +180,6 @@
 				 * TipWin\x83\x81\x83\x93\x83o\x81[\x82\xF0\x81A\x82\xB1\x82\xB1\x82̃^\x83C\x83~\x83\x93\x83O\x82ʼn\xF0\x95\xFA\x82\xB5\x82Ă\xA2\x82\xBD\x82\xBD\x82߁B
 				 * \x90\xB3\x82\xB5\x82\xAD\x82\xCD CVTWindow \x83N\x83\x89\x83X\x82̃f\x83X\x83g\x83\x89\x83N\x83^\x82ʼn\xF0\x95\xFA\x82\xB7\x82\xE9\x81B
 				 */
-			}
 			break;
 		case WM_TIMER:
 			KillTimer(hWnd, self->timerid);
@@ -220,7 +207,13 @@
 
 CTipWin::~CTipWin()
 {
-	Destroy();
+	if(IsExists()) {
+		DestroyWindow(tWin->tip_wnd);
+		DeleteObject(tWin->tip_font);
+		tWin->tip_font = NULL;
+		free((void*)tWin->str);
+		free(tWin);
+	}
 }
 
 ATOM CTipWin::tip_class;
@@ -313,13 +306,6 @@
 	}
 }
 
-VOID CTipWin::Destroy(void)
-{
-	if(IsExists()) {
-		DestroyWindow(tWin->tip_wnd);
-	}
-}
-
 VOID CTipWin::SetHideTimer(int ms)
 {
 	if(IsExists()) {
@@ -433,7 +419,7 @@
 void TipWinDestroy(TipWin* tWin)
 {
 	CTipWin* tipwin = (CTipWin*) tWin;
-	tipwin->Destroy();
+	delete(tipwin);
 }
 
 int TipWinIsExists(TipWin *tWin)

Modified: branches/tootip_classify/teraterm/common/tipwin.h
===================================================================
--- branches/tootip_classify/teraterm/common/tipwin.h	2019-09-15 15:33:23 UTC (rev 8164)
+++ branches/tootip_classify/teraterm/common/tipwin.h	2019-09-15 15:33:25 UTC (rev 8165)
@@ -62,12 +62,10 @@
 	CTipWin(HWND hWnd);
 	~CTipWin(VOID);
 	VOID SetText(TCHAR *str);
-	VOID Destroy(VOID);
 	VOID GetTextWidthHeight(HWND src, const TCHAR *str, int *width, int *height);
 	POINT GetPos(VOID);
 	VOID SetPos(int x, int y);
 	VOID SetHideTimer(int ms);
-	VOID Create(HWND src, int x, int y, const TCHAR *str);
 	BOOL IsExists(VOID);
 	VOID SetVisible(BOOL bVisible);
 	BOOL IsVisible();
@@ -77,6 +75,8 @@
 	TipWin* tWin;
 	static ATOM tip_class;
 	static LRESULT CALLBACK WndProc(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam);
+	VOID Create(HWND src, int x, int y, const TCHAR *str);
+	VOID Destroy(VOID);
 	VOID CalcStrRect(VOID);
 };
 #endif

Modified: branches/tootip_classify/teraterm/teraterm/addsetting.cpp
===================================================================
--- branches/tootip_classify/teraterm/teraterm/addsetting.cpp	2019-09-15 15:33:23 UTC (rev 8164)
+++ branches/tootip_classify/teraterm/teraterm/addsetting.cpp	2019-09-15 15:33:25 UTC (rev 8165)
@@ -640,7 +640,7 @@
 CVisualPropPageDlg::~CVisualPropPageDlg()
 {
 	free((void *)m_psp.pszTitle);
-	TipWin->Destroy();
+	delete TipWin;
 }
 
 // CVisualPropPageDlg \x83\x81\x83b\x83Z\x81[\x83W \x83n\x83\x93\x83h\x83\x89

Modified: branches/tootip_classify/teraterm/teraterm/vtwin.cpp
===================================================================
--- branches/tootip_classify/teraterm/teraterm/vtwin.cpp	2019-09-15 15:33:23 UTC (rev 8164)
+++ branches/tootip_classify/teraterm/teraterm/vtwin.cpp	2019-09-15 15:33:25 UTC (rev 8165)
@@ -809,7 +809,15 @@
 }
 
 /////////////////////////////////////////////////////////////////////////////
+// CVTWindow destructor
 
+CVTWindow::~CVTWindow()
+{
+	delete TipWin;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+
 int CVTWindow::Parse()
 {
 	// added ScrollLock (2006.11.14 yutaka)

Modified: branches/tootip_classify/teraterm/teraterm/vtwin.h
===================================================================
--- branches/tootip_classify/teraterm/teraterm/vtwin.h	2019-09-15 15:33:23 UTC (rev 8164)
+++ branches/tootip_classify/teraterm/teraterm/vtwin.h	2019-09-15 15:33:25 UTC (rev 8165)
@@ -69,6 +69,7 @@
 
 public:
 	CVTWindow(HINSTANCE hInstance);
+	~CVTWindow();
 	int Parse();
 	void ButtonUp(BOOL Paste);
 	void ButtonDown(POINT p, int LMR);


Ttssh2-commit メーリングリストの案内
Back to archive index