Skip to content

Commit ac44e4c

Browse files
committed
don't raise sink events from locked project - fixes #1289
1 parent ded5ab2 commit ac44e4c

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

RetailCoder.VBE/Common/Dispatch/VBProjectsEventsSink.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,26 @@ public class VBProjectsEventsSink : _dispVBProjectsEvents
88
public event EventHandler<DispatcherEventArgs<VBProject>> ProjectAdded;
99
public void ItemAdded(VBProject VBProject)
1010
{
11-
OnDispatch(ProjectAdded, VBProject);
11+
if (VBProject.Protection == vbext_ProjectProtection.vbext_pp_none)
12+
{
13+
OnDispatch(ProjectAdded, VBProject);
14+
}
1215
}
1316

1417
public event EventHandler<DispatcherEventArgs<VBProject>> ProjectRemoved;
1518
public void ItemRemoved(VBProject VBProject)
1619
{
17-
OnDispatch(ProjectRemoved, VBProject);
20+
if (VBProject.Protection == vbext_ProjectProtection.vbext_pp_none)
21+
{
22+
OnDispatch(ProjectRemoved, VBProject);
23+
}
1824
}
1925

2026
public event EventHandler<DispatcherRenamedEventArgs<VBProject>> ProjectRenamed;
2127
public void ItemRenamed(VBProject VBProject, string OldName)
2228
{
2329
var handler = ProjectRenamed;
24-
if (handler != null)
30+
if (handler != null && VBProject.Protection == vbext_ProjectProtection.vbext_pp_none)
2531
{
2632
handler.Invoke(this, new DispatcherRenamedEventArgs<VBProject>(VBProject, OldName));
2733
}
@@ -30,7 +36,10 @@ public void ItemRenamed(VBProject VBProject, string OldName)
3036
public event EventHandler<DispatcherEventArgs<VBProject>> ProjectActivated;
3137
public void ItemActivated(VBProject VBProject)
3238
{
33-
OnDispatch(ProjectActivated, VBProject);
39+
if (VBProject.Protection == vbext_ProjectProtection.vbext_pp_none)
40+
{
41+
OnDispatch(ProjectActivated, VBProject);
42+
}
3443
}
3544

3645
private void OnDispatch(EventHandler<DispatcherEventArgs<VBProject>> dispatched, VBProject project)

0 commit comments

Comments
 (0)