Skip to content

Commit 263b55f

Browse files
committed
Released v1.1, PyNPP now kills the Python it launched when file is re-run
1 parent 3373992 commit 263b55f

File tree

4 files changed

+69
-1
lines changed

4 files changed

+69
-1
lines changed

PluginDefinition.cpp

100644100755
Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "AboutDlg.h"
2323
#include <string>
2424
#include <sstream>
25+
#include <map>
2526
using namespace std;
2627
#include <windows.h>
2728

@@ -33,6 +34,7 @@ FuncItem funcItem[nbFunc];
3334
//
3435
// The data of Notepad++ that you can use in your plugin commands
3536
//
37+
map<std::wstring, PROCESS_INFORMATION> pi_map;
3638

3739

3840
void pluginInit(HANDLE hModule)
@@ -160,7 +162,17 @@ bool launchPython(std::wstring &command, std::wstring &path)
160162
memset(&pi, 0, sizeof(pi));
161163
si.cb = sizeof(si);
162164

163-
return CreateProcess(
165+
bool ok = false;
166+
std::wstring filename = getCurrentFile(ok);
167+
if (ok) {
168+
map<std::wstring, PROCESS_INFORMATION>::iterator it = pi_map.find(filename);
169+
if (it != pi_map.end()) {
170+
TerminateProcess(it->second.hProcess, 1);
171+
pi_map.erase(it);
172+
}
173+
}
174+
175+
bool result = CreateProcess(
164176
NULL,
165177
const_cast<LPWSTR>(command.c_str()),
166178
NULL,
@@ -171,6 +183,11 @@ bool launchPython(std::wstring &command, std::wstring &path)
171183
path.c_str(),
172184
&si,
173185
&pi) != 0;
186+
187+
if (result)
188+
pi_map[filename] = pi;
189+
190+
return result;
174191
}
175192

176193
void run(bool isW, bool isI) {

Unicode Debug/PyNPP.dll

-832 KB
Binary file not shown.

Unicode Release/PyNPP.dll

208 KB
Binary file not shown.

versionRC.rc

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#include <windows.h>
2+
3+
#define VER_FILEVERSION 1,1,0,0
4+
#define VER_FILEVERSION_STR "1.1\0"
5+
6+
#define VER_PRODUCTVERSION 1,1,0,0
7+
#define VER_PRODUCTVERSION_STR "1.1\0"
8+
9+
#ifndef DEBUG
10+
#define VER_DEBUG 0
11+
#else
12+
#define VER_DEBUG VS_FF_DEBUG
13+
#endif
14+
15+
VS_VERSION_INFO VERSIONINFO
16+
FILEVERSION VER_FILEVERSION
17+
PRODUCTVERSION VER_PRODUCTVERSION
18+
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
19+
FILEFLAGS 0x17L
20+
FILEOS VOS__WINDOWS32
21+
FILETYPE VFT_DLL
22+
FILESUBTYPE VFT2_UNKNOWN
23+
BEGIN
24+
BLOCK "StringFileInfo"
25+
BEGIN
26+
BLOCK "040904E4"
27+
BEGIN
28+
VALUE "CompanyName", "Abd Allah Diab\0"
29+
VALUE "FileDescription", "PyNPP Notepad++ Plugin\0"
30+
VALUE "FileVersion", VER_FILEVERSION_STR
31+
VALUE "InternalName", "PyNPP\0"
32+
VALUE "LegalCopyright", "GPLv3\0"
33+
VALUE "OriginalFilename", "PyNPP.dll\0"
34+
VALUE "ProductName", "PyNPP\0"
35+
VALUE "ProductVersion", VER_PRODUCTVERSION_STR
36+
END
37+
END
38+
39+
BLOCK "VarFileInfo"
40+
BEGIN
41+
/* The following line should only be modified for localized versions. */
42+
/* It consists of any number of WORD,WORD pairs, with each pair */
43+
/* describing a language,codepage combination supported by the file. */
44+
/* */
45+
/* For example, a file might have values "0x409,1252" indicating that it */
46+
/* supports English language (0x409) in the Windows ANSI codepage (1252). */
47+
48+
VALUE "Translation", 0x409, 1252
49+
50+
END
51+
END

0 commit comments

Comments
 (0)