Skip to content

Commit bf3b494

Browse files
authored
Merge pull request #38 from gandarez/master
Update NPP plugin platform with latest version
2 parents c2dcc92 + f54b6d4 commit bf3b494

14 files changed

Lines changed: 3087 additions & 1942 deletions

HISTORY.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ History
33
-------
44

55

6+
4.2.0 (2020-10-10)
7+
++++++++++++++++++
8+
9+
- Update NPP plugin platform with latest version.
10+
11+
612
4.1.0 (2019-04-10)
713
++++++++++++++++++
814

WakaTime/PluginInfrastructure/ClikeStringArray.cs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// NPP plugin platform for .Net v0.94.00 by Kasper B. Graversen etc.
22
using System;
33
using System.Collections.Generic;
4+
using System.Reflection;
45
using System.Runtime.InteropServices;
6+
using System.Windows.Forms;
57

68
namespace Kbg.NppPluginNET.PluginInfrastructure
79
{
@@ -18,10 +20,10 @@ public ClikeStringArray(int num, int stringCapacity)
1820
for (int i = 0; i < num; i++)
1921
{
2022
IntPtr item = Marshal.AllocHGlobal(stringCapacity);
21-
Marshal.WriteIntPtr((IntPtr)((int)_nativeArray + (i * IntPtr.Size)), item);
23+
Marshal.WriteIntPtr(_nativeArray + (i * IntPtr.Size), item);
2224
_nativeItems.Add(item);
2325
}
24-
Marshal.WriteIntPtr((IntPtr)((int)_nativeArray + (num * IntPtr.Size)), IntPtr.Zero);
26+
Marshal.WriteIntPtr(_nativeArray + (num * IntPtr.Size), IntPtr.Zero);
2527
}
2628
public ClikeStringArray(List<string> lstStrings)
2729
{
@@ -30,10 +32,10 @@ public ClikeStringArray(List<string> lstStrings)
3032
for (int i = 0; i < lstStrings.Count; i++)
3133
{
3234
IntPtr item = Marshal.StringToHGlobalUni(lstStrings[i]);
33-
Marshal.WriteIntPtr((IntPtr)((int)_nativeArray + (i * IntPtr.Size)), item);
35+
Marshal.WriteIntPtr(_nativeArray + (i * IntPtr.Size), item);
3436
_nativeItems.Add(item);
3537
}
36-
Marshal.WriteIntPtr((IntPtr)((int)_nativeArray + (lstStrings.Count * IntPtr.Size)), IntPtr.Zero);
38+
Marshal.WriteIntPtr(_nativeArray + (lstStrings.Count * IntPtr.Size), IntPtr.Zero);
3739
}
3840

3941
public IntPtr NativePointer { get { return _nativeArray; } }
@@ -52,12 +54,19 @@ List<string> _getManagedItems(bool unicode)
5254

5355
public void Dispose()
5456
{
55-
if (!_disposed)
57+
try
5658
{
57-
for (int i = 0; i < _nativeItems.Count; i++)
58-
if (_nativeItems[i] != IntPtr.Zero) Marshal.FreeHGlobal(_nativeItems[i]);
59-
if (_nativeArray != IntPtr.Zero) Marshal.FreeHGlobal(_nativeArray);
60-
_disposed = true;
59+
if (!_disposed)
60+
{
61+
for (int i = 0; i < _nativeItems.Count; i++)
62+
if (_nativeItems[i] != IntPtr.Zero) Marshal.FreeHGlobal(_nativeItems[i]);
63+
if (_nativeArray != IntPtr.Zero) Marshal.FreeHGlobal(_nativeArray);
64+
_disposed = true;
65+
}
66+
}
67+
catch (Exception e)
68+
{
69+
MessageBox.Show(MethodBase.GetCurrentMethod().ToString() +": "+ e.Message, this.GetType().Name);
6170
}
6271
}
6372
~ClikeStringArray()

WakaTime/PluginInfrastructure/DllExport/NppPlugin.DllExport.targets

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,13 @@
3030
On 32 bit windows usually C:\Program Files\
3131
On 64 bit windows usually C:\Program Files (x86)\
3232
$(ProgramW6432) points to the 64bit Program Files (on 32 bit windows it is blank) -->
33-
<MakeDir
34-
Directories="$(MSBuildProgramFiles32)\Notepad++\plugins\$(TargetName)\"
35-
Condition="Exists('$(MSBuildProgramFiles32)\Notepad++\plugins\') AND !Exists('$(MSBuildProgramFiles32)\Notepad++\plugins\$(TargetName)\') AND '$(Platform)'=='x86'" />
33+
<MakeDir Directories="$(MSBuildProgramFiles32)\Notepad++\plugins\$(TargetName)\" Condition="Exists('$(MSBuildProgramFiles32)\Notepad++\plugins\') AND !Exists('$(MSBuildProgramFiles32)\Notepad++\plugins\$(TargetName)\') AND '$(Platform)'=='x86'" />
3634
<Copy
3735
SourceFiles="$(TargetPath)"
3836
DestinationFolder="$(MSBuildProgramFiles32)\Notepad++\plugins\$(TargetName)\"
3937
Condition="Exists('$(MSBuildProgramFiles32)\Notepad++\plugins\$(TargetName)\') AND '$(Platform)'=='x86'"
40-
ContinueOnError="false" />
41-
<MakeDir
42-
Directories="$(ProgramW6432)\Notepad++\plugins\$(TargetName)\"
43-
Condition="Exists('$(ProgramW6432)\Notepad++\plugins\') AND !Exists('$(ProgramW6432)\Notepad++\plugins\$(TargetName)\') AND '$(Platform)'=='x64'" />
38+
ContinueOnError="false" />
39+
<MakeDir Directories="$(ProgramW6432)\Notepad++\plugins\$(TargetName)\" Condition="Exists('$(ProgramW6432)\Notepad++\plugins\') AND !Exists('$(ProgramW6432)\Notepad++\plugins\$(TargetName)\') AND '$(Platform)'=='x64'" />
4440
<Copy
4541
SourceFiles="$(TargetPath)"
4642
DestinationFolder="$(ProgramW6432)\Notepad++\plugins\$(TargetName)\"

0 commit comments

Comments
 (0)