fernandreu / office-ribbonx-editor

An overhauled fork of the original Custom UI Editor for Microsoft Office, built with WPF
MIT License
523 stars 103 forks source link

The app crashes when you doubleclick inserted icon #131

Closed nbelyh closed 3 years ago

nbelyh commented 3 years ago

Describe the bug The application crashes when double-click on inserted icon.

To Reproduce Steps to reproduce the behavior:

  1. Open Any Office file
  2. Click "Insert Icon"
  3. Double click inserted icon => Application crashes

Expected behavior Application does not crash

Screenshots image

Additional context In most countries decimal separator is set to "," (coma) by default, not "." (dot) You could try using "CultureInfo.InvariantCulture" here to fix the issue, "null" seems to be a problem (it means "current culture"). There are two occurrences of this problem in this file: https://github.com/fernandreu/office-ribbonx-editor/blob/3d587b0dddfab82b1b123ba8b8b29f2670ee9517/src/OfficeRibbonXEditor/Converters/PowerConverter.cs#L19

This is originating from here ("1.2") - dot is used https://github.com/fernandreu/office-ribbonx-editor/blob/3d587b0dddfab82b1b123ba8b8b29f2670ee9517/src/OfficeRibbonXEditor/Views/Controls/IconTab.xaml#L164-L165

Log

System.FormatException: Input string was not in a correct format.
   at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type)
   at System.String.System.IConvertible.ToDouble(IFormatProvider provider)
   at OfficeRibbonXEditor.Converters.PowerConverter.Convert(Object value, Type targetType, Object parameter, CultureInfo culture) in D:\a\1\s\src\OfficeRibbonXEditor\Converters\PowerConverter.cs:line 19
   at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
   at System.Windows.Data.BindingExpression.Activate(Object item)
   at System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt attempt)
   at System.Windows.Data.BindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext(Boolean lastChance)
   at MS.Internal.Data.DataBindEngine.Task.Run(Boolean lastChance)
   at MS.Internal.Data.DataBindEngine.Run(Object arg)
   at MS.Internal.Data.DataBindEngine.OnLayoutUpdated(Object sender, EventArgs e)
   at System.Windows.ContextLayoutManager.fireLayoutUpdateEvent()
   at System.Windows.ContextLayoutManager.UpdateLayout()
   at System.Windows.Interop.HwndSource.SetLayoutSize()
   at System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value)
   at System.Windows.Window.SetRootVisual()
   at System.Windows.Window.SetRootVisualAndUpdateSTC()
   at System.Windows.Window.SetupInitialState(Double requestedTop, Double requestedLeft, Double requestedWidth, Double requestedHeight)
   at System.Windows.Window.CreateSourceWindow(Boolean duringShow)
   at System.Windows.Window.CreateSourceWindowDuringShow()
   at System.Windows.Window.SafeCreateWindowDuringShow()
   at System.Windows.Window.ShowHelper(Object booleanBox)
   at System.Windows.Window.Show()
   at System.Windows.Window.ShowDialog()
   at OfficeRibbonXEditor.App.LaunchDialog(Window mainWindow, IContentDialogBase content, Boolean showDialog) in D:\a\1\s\src\OfficeRibbonXEditor\App.xaml.cs:line 74
   at OfficeRibbonXEditor.App.OnUnhandledException(Object sender, DispatcherUnhandledExceptionEventArgs e) in D:\a\1\s\src\OfficeRibbonXEditor\App.xaml.cs:line 96
   at System.Windows.Threading.Dispatcher.CatchException(Exception e)
   at System.Windows.Threading.Dispatcher.CatchExceptionStatic(Object source, Exception e)
   at System.Windows.Threading.ExceptionWrapper.CatchException(Object source, Exception e, Delegate catchHandler)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
fernandreu commented 3 years ago

Thanks for the bug report! Yeah you are right, using CultureInfo.InvariantCulture in the converter from this build onwards.

I'll double-check there are no other places with a hard-coded number format and a variant culture.