Skip to content

Commit

Permalink
Always remove custom handlers even if the controls is already disposed
Browse files Browse the repository at this point in the history
  • Loading branch information
Timocop committed Jul 16, 2018
1 parent b7fa690 commit c4f5657
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 16 deletions.
3 changes: 2 additions & 1 deletion BasicPawn/Classes/Controls/ClassTextMinimap.vb
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ Public Class ClassTextMinimap
End Sub

Private Sub CleanUp()
If (g_mPanel IsNot Nothing AndAlso Not g_mPanel.IsDisposed) Then
'Remove Handlers
If (g_mPanel IsNot Nothing) Then
RemoveHandler g_mPanel.MouseClick, AddressOf Panel_MouseClick
RemoveHandler g_mPanel.MouseMove, AddressOf Panel_MouseMove
End If
Expand Down
14 changes: 8 additions & 6 deletions BasicPawn/Classes/FormMain/ClassTextEditorTools.vb
Original file line number Diff line number Diff line change
Expand Up @@ -1178,14 +1178,16 @@ Public Class ClassTextEditorTools
Continue For
End If

If (g_lHighlightItemList(i).mToolStripItem Is Nothing OrElse g_lHighlightItemList(i).mToolStripItem.IsDisposed) Then
Continue For
'Remove Handlers
If (g_lHighlightItemList(i).mToolStripItem IsNot Nothing) Then
RemoveHandler g_lHighlightItemList(i).mToolStripItem.Click, AddressOf OnClick
End If

RemoveHandler g_lHighlightItemList(i).mToolStripItem.Click, AddressOf OnClick

g_lHighlightItemList(i).mToolStripItem.Dispose()
g_lHighlightItemList(i).mToolStripItem = Nothing
'Remove Controls
If (g_lHighlightItemList(i).mToolStripItem IsNot Nothing AndAlso Not g_lHighlightItemList(i).mToolStripItem.IsDisposed) Then
g_lHighlightItemList(i).mToolStripItem.Dispose()
g_lHighlightItemList(i).mToolStripItem = Nothing
End If
Next

g_lHighlightItemList.Clear()
Expand Down
11 changes: 11 additions & 0 deletions BasicPawnPluginAutoErrorReport/PluginAutoErrorReport.vb
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,17 @@ Public Class PluginAutoErrorReport
If Not disposedValue Then
If disposing Then
' TODO: dispose managed state (managed objects).

'Remove Handlers
If (g_mReportMoreManagerMenuItem IsNot Nothing) Then
RemoveHandler g_mReportMoreManagerMenuItem.Click, AddressOf OnReportManagerClick
End If

If (g_mReportMoreSettingsMenuItem IsNot Nothing) Then
RemoveHandler g_mReportMoreSettingsMenuItem.Click, AddressOf OnSettingsClick
End If

'Remove Controls
If (g_mReportMenuSplit IsNot Nothing AndAlso Not g_mReportMenuSplit.IsDisposed) Then
g_mReportMenuSplit.Dispose()
g_mReportMenuSplit = Nothing
Expand Down
21 changes: 15 additions & 6 deletions BasicPawnPluginFTP/PluginFTP.vb
Original file line number Diff line number Diff line change
Expand Up @@ -287,30 +287,39 @@ Public Class PluginFTP
If Not disposedValue Then
If disposing Then
' TODO: dispose managed state (managed objects).

'Remove Handlers
RemoveHandler g_mPluginFTP.g_mFormMain.g_mUCProjectBrowser.ContextMenuStrip_ProjectFiles.Opening, AddressOf ContextMenuStripProjectFilesOpening

If (g_mFtpMenuItem IsNot Nothing) Then
RemoveHandler g_mFtpMenuItem.Click, AddressOf OnMenuItemClick
End If

If (g_mFtpCompileItem IsNot Nothing) Then
RemoveHandler g_mFtpCompileItem.Click, AddressOf OnCompileItemClick
End If

If (g_mFtpCompileAllItem IsNot Nothing) Then
RemoveHandler g_mFtpCompileAllItem.Click, AddressOf OnCompileAllItemClick
End If

'Remove Controls
If (g_mFtpMenuSplit IsNot Nothing AndAlso Not g_mFtpMenuSplit.IsDisposed) Then
g_mFtpMenuSplit.Dispose()
g_mFtpMenuSplit = Nothing
End If

If (g_mFtpMenuItem IsNot Nothing AndAlso Not g_mFtpMenuItem.IsDisposed) Then
RemoveHandler g_mFtpMenuItem.Click, AddressOf OnMenuItemClick

g_mFtpMenuItem.Dispose()
g_mFtpMenuItem = Nothing
End If

If (g_mFtpCompileItem IsNot Nothing AndAlso Not g_mFtpCompileItem.IsDisposed) Then
RemoveHandler g_mFtpCompileItem.Click, AddressOf OnCompileItemClick

g_mFtpCompileItem.Dispose()
g_mFtpCompileItem = Nothing
End If

If (g_mFtpCompileAllItem IsNot Nothing AndAlso Not g_mFtpCompileAllItem.IsDisposed) Then
RemoveHandler g_mFtpCompileAllItem.Click, AddressOf OnCompileAllItemClick

g_mFtpCompileAllItem.Dispose()
g_mFtpCompileAllItem = Nothing
End If
Expand Down
12 changes: 9 additions & 3 deletions BasicPawnPluginSample/PluginSample.vb
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,22 @@ Public Class PluginSample
If disposing Then
' TODO: dispose managed state (managed objects).

If (g_mAboutMenuItem IsNot Nothing AndAlso Not g_mAboutMenuItem.IsDisposed) Then
'RemoveHandlers
If (g_mAboutMenuItem IsNot Nothing) Then
RemoveHandler g_mAboutMenuItem.Click, AddressOf OnMenuItemClick
End If

If (g_mTestButton IsNot Nothing) Then
RemoveHandler g_mTestButton.Click, AddressOf OnButtonClick
End If

'Remove Controls
If (g_mAboutMenuItem IsNot Nothing AndAlso Not g_mAboutMenuItem.IsDisposed) Then
g_mAboutMenuItem.Dispose()
g_mAboutMenuItem = Nothing
End If

If (g_mTestButton IsNot Nothing AndAlso Not g_mTestButton.IsDisposed) Then
RemoveHandler g_mTestButton.Click, AddressOf OnButtonClick

g_mTestButton.Dispose()
g_mTestButton = Nothing
End If
Expand Down
Binary file modified Required Plugin References/BasicPawn.exe
Binary file not shown.
Binary file modified Required Plugin References/BasicPawnPluginInterface.dll
Binary file not shown.

0 comments on commit c4f5657

Please sign in to comment.