Unhandled exception on cutting text without selecting when using text tool

Bug #1964398 reported by supershadoe
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Pinta
Fix Released
Undecided
Unassigned

Bug Description

Pinta version 2.0.1 on Arch Linux

When Ctrl+x is pressed with the text tool active, with empty text or some text entered(without finalizing) and without selecting the text, an exception is raised by the app.

Exception details:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.ArgumentException: Invalid start position (Parameter 'start')
   at Pinta.Core.TextEngine.DeleteText(TextPosition start, TextPosition end)
   at Pinta.Core.TextEngine.DeleteSelection()
   at Pinta.Core.TextEngine.PerformCut(Clipboard clipboard)
   at Pinta.Tools.TextTool.OnHandleCut(Document document, Clipboard cb)
   at Pinta.Core.BaseTool.DoHandleCut(Document document, Clipboard clipboard)
   at Pinta.Core.EditActions.HandlerPintaCoreActionsEditCutActivated(Object sender, EventArgs e)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at GLib.Signal.ClosureInvokedCB(Object o, ClosureInvokedArgs args)
   at GLib.SignalClosure.MarshalCallback(IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data)

Tags: text-tool
Revision history for this message
supershadoe (supershadoe) wrote :

I think the issue is that there is no check to see if there is any text selected in PerformCut(); For the copying text part, PerformCopy() performs that check but DeleteSelection() is called with no check.

So, I think adding that one line for check is enough

Revision history for this message
supershadoe (supershadoe) wrote :

Also, I made a pull request fixing this small bug: https://github.com/PintaProject/Pinta/pull/219

Changed in pinta:
milestone: none → 2.1
status: New → Fix Committed
grofaty (grofaty)
Changed in pinta:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.