Permalink
Browse files

Remove unnecessary locks

There is no reason to use a monitor or any other thread synchronization
mechanism in this library.  WinForms are inheriently single-threaded and
the dockpanel can only ever be accessed from the thread on which it was
created.
  • Loading branch information...
1 parent 70a37be commit 8303c2b675b4830301e8bbfa030e02fd4834507f Ryan Rastedt committed Mar 11, 2013
@@ -35,20 +35,17 @@ public void Dispose()
protected virtual void Dispose(bool disposing)
{
- if(disposing)
+ if (disposing)
{
- lock(this)
- {
- DockPanel = null;
- if (m_autoHideTab != null)
- m_autoHideTab.Dispose();
- if (m_tab != null)
- m_tab.Dispose();
-
- Form.Disposed -= new EventHandler(Form_Disposed);
- Form.TextChanged -= new EventHandler(Form_TextChanged);
- m_events.Dispose();
- }
+ DockPanel = null;
+ if (m_autoHideTab != null)
+ m_autoHideTab.Dispose();
+ if (m_tab != null)
+ m_tab.Dispose();
+
+ Form.Disposed -= new EventHandler(Form_Disposed);
+ Form.TextChanged -= new EventHandler(Form_TextChanged);
+ m_events.Dispose();
}
}
@@ -956,13 +956,10 @@ private void ResumeRefreshStateChange(INestedPanesContainer oldContainer, DockSt
private void RefreshStateChange(INestedPanesContainer oldContainer, DockState oldDockState)
{
- lock (this)
- {
- if (IsRefreshStateChangeSuspended)
- return;
+ if (IsRefreshStateChangeSuspended)
+ return;
- SuspendRefreshStateChange();
- }
+ SuspendRefreshStateChange();
DockPanel.SuspendLayout(true);
@@ -37,23 +37,19 @@ protected Point StartMousePosition
protected bool BeginDrag()
{
- // Avoid re-entrance;
- lock (this)
- {
- if (DragControl == null)
- return false;
-
- StartMousePosition = Control.MousePosition;
-
- if (!Win32Helper.IsRunningOnMono)
- if (!NativeMethods.DragDetect(DragControl.Handle, StartMousePosition))
- return false;
-
- DragControl.FindForm().Capture = true;
- AssignHandle(DragControl.FindForm().Handle);
- Application.AddMessageFilter(this);
- return true;
- }
+ if (DragControl == null)
+ return false;
+
+ StartMousePosition = Control.MousePosition;
+
+ if (!Win32Helper.IsRunningOnMono)
+ if (!NativeMethods.DragDetect(DragControl.Handle, StartMousePosition))
+ return false;
+
+ DragControl.FindForm().Capture = true;
+ AssignHandle(DragControl.FindForm().Handle);
+ Application.AddMessageFilter(this);
+ return true;
}
protected abstract void OnDragging();
@@ -150,17 +150,14 @@ public DockPanel DockPanel
private bool m_disposed = false;
protected override void Dispose(bool disposing)
{
- lock (this)
+ if (!m_disposed && disposing)
{
- if (!m_disposed && disposing)
- {
- if (!Win32Helper.IsRunningOnMono)
- sm_localWindowsHook.HookInvoked -= m_hookEventHandler;
- m_disposed = true;
- }
-
- base.Dispose(disposing);
+ if (!Win32Helper.IsRunningOnMono)
+ sm_localWindowsHook.HookInvoked -= m_hookEventHandler;
+ m_disposed = true;
}
+
+ base.Dispose(disposing);
}
private IDockContent m_contentActivating = null;
@@ -33,14 +33,11 @@ protected virtual void Dispose(bool disposing)
{
if (disposing)
{
- lock (this)
- {
- if (Site != null && Site.Container != null)
- Site.Container.Remove(this);
+ if (Site != null && Site.Container != null)
+ Site.Container.Remove(this);
- if (Disposed != null)
- Disposed(this, EventArgs.Empty);
- }
+ if (Disposed != null)
+ Disposed(this, EventArgs.Empty);
}
}
@@ -150,27 +150,24 @@ private void MdiClient_Layout(object sender, LayoutEventArgs e)
private bool m_disposed = false;
protected override void Dispose(bool disposing)
{
- lock (this)
+ if (!m_disposed && disposing)
{
- if (!m_disposed && disposing)
+ m_focusManager.Dispose();
+ if (m_mdiClientController != null)
{
- m_focusManager.Dispose();
- if (m_mdiClientController != null)
- {
- m_mdiClientController.HandleAssigned -= new EventHandler(MdiClientHandleAssigned);
- m_mdiClientController.MdiChildActivate -= new EventHandler(ParentFormMdiChildActivate);
- m_mdiClientController.Layout -= new LayoutEventHandler(MdiClient_Layout);
- m_mdiClientController.Dispose();
- }
- FloatWindows.Dispose();
- Panes.Dispose();
- DummyContent.Dispose();
-
- m_disposed = true;
+ m_mdiClientController.HandleAssigned -= new EventHandler(MdiClientHandleAssigned);
+ m_mdiClientController.MdiChildActivate -= new EventHandler(ParentFormMdiChildActivate);
+ m_mdiClientController.Layout -= new LayoutEventHandler(MdiClient_Layout);
+ m_mdiClientController.Dispose();
}
-
- base.Dispose(disposing);
+ FloatWindows.Dispose();
+ Panes.Dispose();
+ DummyContent.Dispose();
+
+ m_disposed = true;
}
+
+ base.Dispose(disposing);
}
[Browsable(false)]

0 comments on commit 8303c2b

Please sign in to comment.