[Ttssh2-commit] [8449] ドラッグアンドドロップからのファイル送信が2回目以降できなかったので修正

scmno****@osdn***** scmno****@osdn*****
2019年 12月 28日 (土) 18:02:33 JST


Revision: 8449
          https://osdn.net/projects/ttssh2/scm/svn/commits/8449
Author:   zmatsuo
Date:     2019-12-28 18:02:32 +0900 (Sat, 28 Dec 2019)
Log Message:
-----------
ドラッグアンドドロップからのファイル送信が2回目以降できなかったので修正

- 1回しか送信できなかった
- 不要な NewFileVar(&SendVar) を削除
- SendMemPasteString() で free() 抜け

Modified Paths:
--------------
    trunk/teraterm/teraterm/sendmem.cpp
    trunk/teraterm/teraterm/vtwin.cpp

-------------- next part --------------
Modified: trunk/teraterm/teraterm/sendmem.cpp
===================================================================
--- trunk/teraterm/teraterm/sendmem.cpp	2019-12-23 09:26:17 UTC (rev 8448)
+++ trunk/teraterm/teraterm/sendmem.cpp	2019-12-28 09:02:32 UTC (rev 8449)
@@ -503,11 +503,24 @@
 	free(sm);
 }
 
+/**
+ *	\x83t\x83@\x83C\x83\x8B\x82𑗐M\x82\xB7\x82\xE9
+ *	@param[in]	filename	\x83t\x83@\x83C\x83\x8B\x96\xBC
+ *	@param[in]	binary		FALSE	text file
+ *							TRUE	binary file
+ */
 #if SENDMEM_USE_OLD_API
 BOOL SendMemSendFile(const wchar_t *filename, BOOL binary)
 {
+	if (SendVar != NULL) {
+		return FALSE;
+	}
+	if (!NewFileVar(&SendVar)) {
+		return FALSE;
+	}
+
 	char *FileNameA = ToCharW(filename);
-	strncpy_s(SendVar->FullName, sizeof(SendVar->FullName), FileNameA,  _TRUNCATE);
+	strncpy_s(SendVar->FullName, sizeof(SendVar->FullName), FileNameA, _TRUNCATE);
 	free(FileNameA);
 
 	SendVar->DirLen = 0;
@@ -516,7 +529,7 @@
 	return TRUE;
 }
 #else
-BOOL SendMemSendFile(const wchar_t *filename, BOOL binary)
+BOOL SendMemSendFile(const wchar_t *filename, BOOL binary)	// binary\x96\xA2\x91Ή\x9E
 {
 	binary = FALSE;
 
@@ -551,5 +564,6 @@
 		CommTextEchoW(&cv, str, len);
 	}
 
+	free(str);
 	return TRUE;
 }

Modified: trunk/teraterm/teraterm/vtwin.cpp
===================================================================
--- trunk/teraterm/teraterm/vtwin.cpp	2019-12-23 09:26:17 UTC (rev 8448)
+++ trunk/teraterm/teraterm/vtwin.cpp	2019-12-28 09:02:32 UTC (rev 8449)
@@ -1833,7 +1833,6 @@
 
 static void PasteString(PComVar cv, const wchar_t *str, bool escape)
 {
-	wchar_t *ptr = (wchar_t *)str;
 	wchar_t *tmpbuf;
 	if (!escape) {
 		tmpbuf = _wcsdup(str);
@@ -1842,7 +1841,6 @@
 		const size_t len = wcslen(str) * sizeof(wchar_t) * 2;
 		tmpbuf = (wchar_t *)malloc(len);
 		EscapeFilename(str, tmpbuf);
-		ptr = tmpbuf;
 	}
 
 	SendMemPasteString(tmpbuf);
@@ -1874,7 +1872,7 @@
 
 	for (int i = 0; i < FileCount; i++) {
 		char *FileName = ToU8W(Filenames[i]);
-		func((char *)FileName, ts.ScpSendDir);
+		func(FileName, ts.ScpSendDir);
 		free(FileName);
 	}
 	return true;
@@ -2019,10 +2017,10 @@
 			// cancel
 			break;
 		case DROP_TYPE_SEND_FILE:
+			SendMemSendFile(FileName, FALSE);
+			break;
 		case DROP_TYPE_SEND_FILE_BINARY:
-			if (SendVar==NULL && NewFileVar(&SendVar)) {
-				SendMemSendFile(FileName, DropType == DROP_TYPE_SEND_FILE ? FALSE : TRUE);
-			}
+			SendMemSendFile(FileName, TRUE);
 			break;
 		case DROP_TYPE_PASTE_FILENAME:
 		{


Ttssh2-commit メーリングリストの案内