Browse Source

Fixed SD2-607: Null Reference exception on closing form designer.

Applied text editor IME patch by Shinsaku Nakagawa and form designer unloading patch by Christian Hornung.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@910 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
59a5ede785
  1. 6
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerViewContent.cs
  2. 5
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextArea.cs
  3. 3
      src/Main/Base/Project/Src/Gui/AbstractBaseViewContent.cs
  4. 3
      src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/ProjectBrowserPad.cs
  5. 10
      src/Main/Base/Project/Src/Gui/Workbench/DefaultWorkbench.cs
  6. 11
      src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs
  7. 4
      src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs
  8. 5
      src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs
  9. 13
      src/Main/StartUp/Project/Dialogs/SplashScreen.cs

6
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerViewContent.cs

@ -149,7 +149,6 @@ namespace ICSharpCode.FormsDesigner
serviceContainer.AddService(typeof(System.ComponentModel.Design.IEventBindingService), eventBindingService); serviceContainer.AddService(typeof(System.ComponentModel.Design.IEventBindingService), eventBindingService);
designerResourceService.Host = Host; designerResourceService.Host = Host;
serviceContainer.AddService(typeof(IDesignerHost), Host);
DesignerLoader designerLoader = loaderProvider.CreateLoader(generator); DesignerLoader designerLoader = loaderProvider.CreateLoader(generator);
designSurface.BeginLoad(designerLoader); designSurface.BeginLoad(designerLoader);
@ -309,7 +308,10 @@ namespace ICSharpCode.FormsDesigner
public override void Deselected() public override void Deselected()
{ {
LoggingService.Info("Deselected form designer, unloading..."); // can happen if form designer is disposed and then deselected
if (!IsFormsDesignerVisible)
return;
LoggingService.Info("Deselected form designer, unloading..." + viewContent.TitleName);
PropertyPad.PropertyValueChanged -= PropertyValueChanged; PropertyPad.PropertyValueChanged -= PropertyValueChanged;
propertyContainer.Clear(); propertyContainer.Clear();
IsFormsDesignerVisible = false; IsFormsDesignerVisible = false;

5
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextArea.cs

@ -34,7 +34,7 @@ namespace ICSharpCode.TextEditor
/// This class paints the textarea. /// This class paints the textarea.
/// </summary> /// </summary>
[ToolboxItem(false)] [ToolboxItem(false)]
public class TextArea : UserControl public class TextArea : Control
{ {
public static bool HiddenMouseCursor = false; public static bool HiddenMouseCursor = false;
@ -585,10 +585,11 @@ namespace ICSharpCode.TextEditor
} }
} }
protected override void OnKeyPress(System.Windows.Forms.KeyPressEventArgs e) protected override void OnKeyPress(KeyPressEventArgs e)
{ {
base.OnKeyPress(e); base.OnKeyPress(e);
SimulateKeyPress(e.KeyChar); SimulateKeyPress(e.KeyChar);
e.Handled = true;
} }
/// <summary> /// <summary>

3
src/Main/Base/Project/Src/Gui/AbstractBaseViewContent.cs

@ -46,14 +46,13 @@ namespace ICSharpCode.SharpDevelop.Gui
{ {
} }
public virtual void RedrawContent() public virtual void RedrawContent()
{ {
} }
public virtual void Dispose() public virtual void Dispose()
{ {
//workbenchWindow = null; workbenchWindow = null;
} }
protected virtual void OnWorkbenchWindowChanged(EventArgs e) protected virtual void OnWorkbenchWindowChanged(EventArgs e)

3
src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/ProjectBrowserPad.cs

@ -83,7 +83,8 @@ namespace ICSharpCode.SharpDevelop.Project
if (WorkbenchSingleton.Workbench.ActiveContent == this) { if (WorkbenchSingleton.Workbench.ActiveContent == this) {
projectBrowserPanel.ProjectBrowserControl.PadActivated(); projectBrowserPanel.ProjectBrowserControl.PadActivated();
} else { } else {
if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow == null) { IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
if (window == null) {
return; return;
} }
string fileName = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent.FileName; string fileName = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent.FileName;

10
src/Main/Base/Project/Src/Gui/Workbench/DefaultWorkbench.cs

@ -75,20 +75,18 @@ namespace ICSharpCode.SharpDevelop.Gui
} }
} }
EventHandler windowChangeEventHandler;
public IWorkbenchLayout WorkbenchLayout { public IWorkbenchLayout WorkbenchLayout {
get { get {
return layout; return layout;
} }
set { set {
if (layout != null) { if (layout != null) {
layout.ActiveWorkbenchWindowChanged -= windowChangeEventHandler; layout.ActiveWorkbenchWindowChanged -= OnActiveWindowChanged;
layout.Detach(); layout.Detach();
} }
value.Attach(this); value.Attach(this);
layout = value; layout = value;
layout.ActiveWorkbenchWindowChanged += windowChangeEventHandler; layout.ActiveWorkbenchWindowChanged += OnActiveWindowChanged;
} }
} }
@ -131,8 +129,6 @@ namespace ICSharpCode.SharpDevelop.Gui
Text = ResourceService.GetString("MainWindow.DialogName"); Text = ResourceService.GetString("MainWindow.DialogName");
Icon = ResourceService.GetIcon("Icons.SharpDevelopIcon"); Icon = ResourceService.GetIcon("Icons.SharpDevelopIcon");
windowChangeEventHandler = new EventHandler(OnActiveWindowChanged);
StartPosition = FormStartPosition.Manual; StartPosition = FormStartPosition.Manual;
AllowDrop = true; AllowDrop = true;
} }
@ -197,7 +193,7 @@ namespace ICSharpCode.SharpDevelop.Gui
} }
} finally { } finally {
closeAll = false; closeAll = false;
OnActiveWindowChanged(null, null); OnActiveWindowChanged(this, EventArgs.Empty);
} }
} }

11
src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs

@ -587,13 +587,22 @@ namespace ICSharpCode.SharpDevelop.Gui
IWorkbenchWindow oldSelectedWindow = null; IWorkbenchWindow oldSelectedWindow = null;
public virtual void OnActiveWorkbenchWindowChanged(EventArgs e) public virtual void OnActiveWorkbenchWindowChanged(EventArgs e)
{ {
IWorkbenchWindow newWindow = this.ActiveWorkbenchwindow;
if (newWindow == null || newWindow.ViewContent != null) {
if (ActiveWorkbenchWindowChanged != null) { if (ActiveWorkbenchWindowChanged != null) {
ActiveWorkbenchWindowChanged(this, e); ActiveWorkbenchWindowChanged(this, e);
} }
//if (newWindow == null)
// LoggingService.Debug("window change to null");
//else
// LoggingService.Debug("window change to " + newWindow);
} else {
//LoggingService.Debug("ignore window change to disposed window");
}
if (oldSelectedWindow != null) { if (oldSelectedWindow != null) {
oldSelectedWindow.OnWindowDeselected(EventArgs.Empty); oldSelectedWindow.OnWindowDeselected(EventArgs.Empty);
} }
oldSelectedWindow = ActiveWorkbenchwindow; oldSelectedWindow = newWindow;
if (oldSelectedWindow != null && oldSelectedWindow.ActiveViewContent != null && oldSelectedWindow.ActiveViewContent.Control != null) { if (oldSelectedWindow != null && oldSelectedWindow.ActiveViewContent != null && oldSelectedWindow.ActiveViewContent.Control != null) {
oldSelectedWindow.OnWindowSelected(EventArgs.Empty); oldSelectedWindow.OnWindowSelected(EventArgs.Empty);
oldSelectedWindow.ActiveViewContent.SwitchedTo(); oldSelectedWindow.ActiveViewContent.SwitchedTo();

4
src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs

@ -97,8 +97,6 @@ namespace ICSharpCode.SharpDevelop.Gui
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
base.Dispose(disposing);
if (disposing) { if (disposing) {
if (content != null) if (content != null)
DetachContent(); DetachContent();
@ -107,6 +105,8 @@ namespace ICSharpCode.SharpDevelop.Gui
this.TabPageContextMenu = null; this.TabPageContextMenu = null;
} }
} }
// DetachContent must be called before the controls are disposed
base.Dispose(disposing);
} }
public SdiWorkspaceWindow(IViewContent content) public SdiWorkspaceWindow(IViewContent content)

5
src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs

@ -162,7 +162,10 @@ namespace ICSharpCode.SharpDevelop.Project
if (viewContent == null && activeContent is ISecondaryViewContent) { if (viewContent == null && activeContent is ISecondaryViewContent) {
// required if one creates a new winforms app and then immediately switches to design mode // required if one creates a new winforms app and then immediately switches to design mode
// without focussing the text editor // without focussing the text editor
viewContent = ((ISecondaryViewContent)activeContent).WorkbenchWindow.ViewContent; IWorkbenchWindow window = ((ISecondaryViewContent)activeContent).WorkbenchWindow;
if (window == null) // workbench window is being disposed
return;
viewContent = window.ViewContent;
} }
if (OpenSolution == null || viewContent == null) { if (OpenSolution == null || viewContent == null) {
return; return;

13
src/Main/StartUp/Project/Dialogs/SplashScreen.cs

@ -7,6 +7,7 @@
using System; using System;
using System.Collections; using System.Collections;
using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using System.Drawing; using System.Drawing;
using System.Reflection; using System.Reflection;
@ -16,7 +17,7 @@ namespace ICSharpCode.SharpDevelop
{ {
public class SplashScreenForm : Form public class SplashScreenForm : Form
{ {
public const string VersionText = "Corsavy alpha rev. " + RevisionClass.Revision; public const string VersionText = "Corsavy Beta 1, rev. " + RevisionClass.Revision;
static SplashScreenForm splashScreen = new SplashScreenForm(); static SplashScreenForm splashScreen = new SplashScreenForm();
static ArrayList requestedFileList = new ArrayList(); static ArrayList requestedFileList = new ArrayList();
@ -37,17 +38,19 @@ namespace ICSharpCode.SharpDevelop
FormBorderStyle = FormBorderStyle.None; FormBorderStyle = FormBorderStyle.None;
StartPosition = FormStartPosition.CenterScreen; StartPosition = FormStartPosition.CenterScreen;
ShowInTaskbar = false; ShowInTaskbar = false;
bitmap = new Bitmap(Assembly.GetEntryAssembly().GetManifestResourceStream("Resources.SplashScreen.jpg"));
Size = bitmap.Size;
#if DEBUG #if DEBUG
string versionText = VersionText + " (debug)"; string versionText = VersionText + " (debug)";
#else #else
string versionText = VersionText; string versionText = VersionText;
#endif #endif
using (Font font = new Font("Vrinda", 4)) { using (Stream stream = Assembly.GetEntryAssembly().GetManifestResourceStream("Resources.SplashScreen.jpg")) {
bitmap = new Bitmap(stream);
}
this.ClientSize = bitmap.Size;
using (Font font = new Font("Sans Serif", 4)) {
using (Graphics g = Graphics.FromImage(bitmap)) { using (Graphics g = Graphics.FromImage(bitmap)) {
g.DrawRectangle(Pens.Black, 0, 0, bitmap.Size.Width - 1, bitmap.Size.Height - 1); g.DrawRectangle(Pens.Black, 0, 0, bitmap.Size.Width - 1, bitmap.Size.Height - 1);
g.DrawString(versionText, font, Brushes.Black, 116, 142); g.DrawString(versionText, font, Brushes.Black, 106, 142);
} }
} }
BackgroundImage = bitmap; BackgroundImage = bitmap;

Loading…
Cancel
Save