diff --git a/GUI/Controls/HackyPropertyGrid.cs b/GUI/Controls/HackyPropertyGrid.cs new file mode 100644 index 000000000..ef80c36cf --- /dev/null +++ b/GUI/Controls/HackyPropertyGrid.cs @@ -0,0 +1,85 @@ +/* + Copyright 2015 MCGalaxy + + Dual-licensed under the Educational Community License, Version 2.0 and + the GNU General Public License, Version 3 (the "Licenses"); you may + not use this file except in compliance with the Licenses. You may + obtain a copy of the Licenses at + + http://www.opensource.org/licenses/ecl2.php + http://www.gnu.org/licenses/gpl-3.0.html + + Unless required by applicable law or agreed to in writing, + software distributed under the Licenses are distributed on an "AS IS" + BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + or implied. See the Licenses for the specific language governing + permissions and limitations under the Licenses. + */ +using System; +using System.Drawing; +using System.Windows.Forms; +using System.Windows.Forms.Design; +using System.Windows.Forms.PropertyGridInternal; + +namespace MCGalaxy.Gui { + /// Hacky workaround class to fix crashing with some versions of wine-mono + public sealed class HackyPropertyGrid : PropertyGrid { + + sealed class HackyPropertiesTab : PropertiesTab { + + // With some versions of wine-mono, if you try to change PropertyGrid's selected object, + // some Exceptions gets thrown. (see examples below) + // The root cause of the Exception is a PropertiesTab instance returning 'null' from its + // Bitmap property implementation - so workaround this by never returning null. + public override Bitmap Bitmap { + get { return base.Bitmap ?? new Bitmap(16, 16); } + } + } + protected override PropertyTab CreatePropertyTab(Type tabType) { return new HackyPropertiesTab(); } + + /* +Type: IndexOutOfRangeException +Source: System.Windows.Forms +Message: Index was outside the bounds of the array. +Target: UpdatePropertiesViewTabVisibility +Trace: at System.Windows.Forms.PropertyGrid.UpdatePropertiesViewTabVisibility () + at System.Windows.Forms.PropertyGrid.ShowEventsButton (System.Boolean value) + at System.Windows.Forms.PropertyGrid.set_SelectedObjects (System.Object[] value) + at System.Windows.Forms.PropertyGrid.set_SelectedObject (System.Object value) + at (wrapper remoting-invoke-with-check) System.Windows.Forms.PropertyGrid.set_SelectedObject(object) + at MCGalaxy.Gui.Window.pl_listBox_Click (System.Object sender, System.EventArgs e) + at System.Windows.Forms.Control.OnClick (System.EventArgs e) + at System.Windows.Forms.ListBox.WndProc (System.Windows.Forms.Messagem) + at System.Windows.Forms.Control+ControlNativeWindow.OnMessage (System.Windows.Forms.Messagem) + at System.Windows.Forms.Control+ControlNativeWindow.WndProc (System.Windows.Forms.Messagem) + at System.Windows.Forms.NativeWindow.Callback (System.IntPtr hWnd, System.Int32 msg, System.IntPtr wparam, System.IntPtr lparam) + */ + /* +Type: IndexOutOfRangeException +Source: System.Windows.Forms +Message: Index was outside the bounds of the array. +Target: RefreshProperties +Trace: at System.Windows.Forms.PropertyGrid.RefreshProperties (System.Boolean clearCached) + at System.Windows.Forms.PropertyGrid.Refresh (System.Boolean clearCached) + at System.Windows.Forms.PropertyGrid.Refresh () + at System.Windows.Forms.PropertyGrid.OnFontChanged (System.EventArgs e) + at System.Windows.Forms.Control.AssignParent (System.Windows.Forms.Control value) + at System.Windows.Forms.Control+ControlCollection.Add (System.Windows.Forms.Control value) + at System.Windows.Forms.TabPage+TabPageControlCollection.Add (System.Windows.Forms.Control value) + at MCGalaxy.Gui.PropertyWindow.InitializeComponent () + at MCGalaxy.Gui.PropertyWindow..ctor () + at (wrapper remoting-invoke-with-check) MCGalaxy.Gui.PropertyWindow..ctor() + at MCGalaxy.Gui.Window.btnProperties_Click (System.Object sender, System.EventArgs e) + at System.Windows.Forms.Control.OnClick (System.EventArgs e) + at System.Windows.Forms.Button.OnClick (System.EventArgs e) + at System.Windows.Forms.Button.OnMouseUp (System.Windows.Forms.MouseEventArgs mevent) + at System.Windows.Forms.Control.WmMouseUp (System.Windows.Forms.Messagem, System.Windows.Forms.MouseButtons button, System.Int32 clicks) + at System.Windows.Forms.Control.WndProc (System.Windows.Forms.Messagem) + at System.Windows.Forms.ButtonBase.WndProc (System.Windows.Forms.Messagem) + at System.Windows.Forms.Button.WndProc (System.Windows.Forms.Messagem) + at System.Windows.Forms.Control+ControlNativeWindow.OnMessage (System.Windows.Forms.Messagem) + at System.Windows.Forms.Control+ControlNativeWindow.WndProc (System.Windows.Forms.Messagem) + at System.Windows.Forms.NativeWindow.Callback (System.IntPtr hWnd, System.Int32 msg, System.IntPtr wparam, System.IntPtr lparam) + */ + } +} \ No newline at end of file diff --git a/GUI/MCGalaxyGUI.csproj b/GUI/MCGalaxyGUI.csproj index d2fff9ae5..420ad7223 100644 --- a/GUI/MCGalaxyGUI.csproj +++ b/GUI/MCGalaxyGUI.csproj @@ -56,6 +56,7 @@ Component + diff --git a/GUI/PropertyWindow/PropertyWindow.Designer.cs b/GUI/PropertyWindow/PropertyWindow.Designer.cs index 6db2662ab..d83e4d85a 100644 --- a/GUI/PropertyWindow/PropertyWindow.Designer.cs +++ b/GUI/PropertyWindow/PropertyWindow.Designer.cs @@ -364,7 +364,7 @@ namespace MCGalaxy.Gui this.zs_lstNotUsed = new System.Windows.Forms.ListBox(); this.zs_lstUsed = new System.Windows.Forms.ListBox(); this.tabZS_old = new System.Windows.Forms.TabPage(); - this.propsZG = new System.Windows.Forms.PropertyGrid(); + this.propsZG = new MCGalaxy.Gui.HackyPropertyGrid(); this.tabCTF = new System.Windows.Forms.TabPage(); this.ctf_grpControls = new System.Windows.Forms.GroupBox(); this.ctf_btnEnd = new System.Windows.Forms.Button(); diff --git a/GUI/Window/Window.Designer.cs b/GUI/Window/Window.Designer.cs index 8dd90fcf6..5b031facc 100644 --- a/GUI/Window/Window.Designer.cs +++ b/GUI/Window/Window.Designer.cs @@ -112,7 +112,7 @@ namespace MCGalaxy.Gui this.tabs = new System.Windows.Forms.TabControl(); this.tp_Maps = new System.Windows.Forms.TabPage(); this.map_gbProps = new System.Windows.Forms.GroupBox(); - this.map_pgProps = new System.Windows.Forms.PropertyGrid(); + this.map_pgProps = new MCGalaxy.Gui.HackyPropertyGrid(); this.map_gbLoaded = new System.Windows.Forms.GroupBox(); this.map_lbLoaded = new System.Windows.Forms.ListBox(); this.map_gbUnloaded = new System.Windows.Forms.GroupBox(); @@ -134,7 +134,7 @@ namespace MCGalaxy.Gui this.map_txtName = new System.Windows.Forms.TextBox(); this.tp_Players = new System.Windows.Forms.TabPage(); this.pl_gbProps = new System.Windows.Forms.GroupBox(); - this.pl_pgProps = new System.Windows.Forms.PropertyGrid(); + this.pl_pgProps = new MCGalaxy.Gui.HackyPropertyGrid(); this.pl_gbOther = new System.Windows.Forms.GroupBox(); this.pl_txtImpersonate = new System.Windows.Forms.TextBox(); this.pl_btnSendCommand = new System.Windows.Forms.Button();