[Ttssh2-commit] [7636] ttsshのauth dialogで、クリップボードが空の時、ペーストメニューをdisableとした

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2019年 4月 30日 (火) 01:22:43 JST


Revision: 7636
          https://osdn.net/projects/ttssh2/scm/svn/commits/7636
Author:   zmatsuo
Date:     2019-04-30 01:22:43 +0900 (Tue, 30 Apr 2019)
Log Message:
-----------
ttsshのauth dialogで、クリップボードが空の時、ペーストメニューをdisableとした
C4005 malloc,free マクロが再定義警告を回避

Modified Paths:
--------------
    trunk/ttssh2/ttxssh/auth.c

-------------- next part --------------
Modified: trunk/ttssh2/ttxssh/auth.c
===================================================================
--- trunk/ttssh2/ttxssh/auth.c	2019-04-29 16:22:21 UTC (rev 7635)
+++ trunk/ttssh2/ttxssh/auth.c	2019-04-29 16:22:43 UTC (rev 7636)
@@ -47,7 +47,7 @@
 #include "tipwin.h"
 #include "auth.h"
 
-#if defined(_DEBUG)
+#if defined(_DEBUG) && !defined(_CRTDBG_MAP_ALLOC)
 #define malloc(l) _malloc_dbg((l), _NORMAL_BLOCK, __FILE__, __LINE__)
 #define free(p)   _free_dbg((p), _NORMAL_BLOCK)
 #endif
@@ -1060,16 +1060,17 @@
 			HWND hWndButton;
 			int result;
 			HMENU hMenu= CreatePopupMenu();
+			char *clipboard = GetClipboardTextA(dlg, FALSE);
 			GetI18nStrT("TTSSH", "DLG_AUTH_PASTE_CLIPBOARD",
 						uimsg, _countof(uimsg),
 						"Paste from &clipboard",
 						pvar->ts->UILanguageFile);
-			AppendMenu(hMenu, MF_ENABLED | MF_STRING, 1, uimsg);
+			AppendMenu(hMenu, MF_ENABLED | MF_STRING | (clipboard == NULL ? MFS_DISABLED : 0), 1, uimsg);
 			GetI18nStrT("ttssh", "DLG_AUTH_CLEAR_CLIPBOARD",
 						uimsg, _countof(uimsg),
 						"Paste from &clipboard and cl&ear clipboard",
 						pvar->ts->UILanguageFile);
-			AppendMenu(hMenu, MF_ENABLED | MF_STRING, 2, uimsg);
+			AppendMenu(hMenu, MF_ENABLED | MF_STRING | (clipboard == NULL ? MFS_DISABLED : 0), 2, uimsg);
 			GetI18nStrT("ttssh", "DLG_AUTH_USE_CONTORL_CHARACTERS",
 						uimsg, _countof(uimsg),
 						"Use control charac&ters",
@@ -1080,6 +1081,9 @@
 						"&Show passphrase",
 						pvar->ts->UILanguageFile);
 			AppendMenu(hMenu, MF_ENABLED | MF_STRING | (ShowPassPhrase ? MFS_CHECKED : 0), 4, uimsg);
+			if (clipboard != NULL) {
+				free(clipboard);
+			}
 			hWndButton = GetDlgItem(dlg, IDC_SSHPASSWORD_OPTION);
 			GetWindowRect(hWndButton, &rect);
 			result = TrackPopupMenu(hMenu, TPM_RETURNCMD, rect.left, rect.bottom, 0 , hWndButton, NULL);
@@ -1089,7 +1093,7 @@
 			case 2: {
 				// \x83N\x83\x8A\x83b\x83v\x83{\x81[\x83h\x82\xA9\x82\xE7\x83y\x81[\x83X\x83g
 				BOOL clear_clipboard = result == 2;
-				char *clipboard = GetClipboardTextA(dlg, clear_clipboard);
+				clipboard = GetClipboardTextA(dlg, clear_clipboard);
 				if (clipboard != NULL) {
 					SetDlgItemTextA(dlg, IDC_SSHPASSWORD, clipboard);
 					free(clipboard);


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