Unhandled exception when Save As to R/O directory

Bug #1715150 reported by Hugh Wormington
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Pinta
Fix Released
Medium
Unassigned

Bug Description

Pinta not handling failed Save As to R/O directory (Ubuntu 16.04).

I opened a jpg for editing (e.g. myimage.jpg), immediately clicked Save As and entered a new name (e.g. myimage2.jpg), and clicked OK then got unhandled exception (see below). After the exception the Cancel button in the Save As because unresponsive.

I tried the same thing with a different image and got same result.

I noticed the directory permissions were dr-xr-xr-x. I changed permissions to drwxrwxr-x and was able to do Save As.

Backtrace:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> GLib.GException: Failed to open '/home/hugh/files/xxxx.png' for writing: Permission denied
  at Pinta.Actions.SaveDocumentImplmentationAction.SaveFile (Pinta.Core.Document document, System.String file, Pinta.Core.FormatDescriptor format, Gtk.Window parent) <0x41955390 + 0x00513> in <filename unknown>:0
  at Pinta.Actions.SaveDocumentImplmentationAction.SaveFileAs (Pinta.Core.Document document) <0x419479b0 + 0x00a17> in <filename unknown>:0
  at Pinta.Actions.SaveDocumentImplmentationAction.Activated (System.Object sender, Pinta.Core.DocumentCancelEventArgs e) <0x41947890 + 0x0005b> in <filename unknown>:0
  at Pinta.Core.FileActions.RaiseSaveDocument (Pinta.Core.Document document, Boolean saveAs) <0x41947750 + 0x0006d> in <filename unknown>:0
  at Pinta.Core.Document.Save (Boolean saveAs) <0x41947700 + 0x00033> in <filename unknown>:0
  at Pinta.Actions.SaveDocumentAsAction.Activated (System.Object sender, System.EventArgs e) <0x419476c0 + 0x00027> in <filename unknown>:0
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) <0x7faa255ab9e0 + 0x000a1> in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) <0x7faa255ab9e0 + 0x000ef> in <filename unknown>:0
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) <0x7faa253e3cf0 + 0x0002a> in <filename unknown>:0
  at System.Delegate.DynamicInvokeImpl (System.Object[] args) <0x7faa25663f60 + 0x0024c> in <filename unknown>:0
  at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) <0x7faa2566c040 + 0x00035> in <filename unknown>:0
  at System.Delegate.DynamicInvoke (System.Object[] args) <0x7faa25663e80 + 0x00019> in <filename unknown>:0
  at GLib.Signal.ClosureInvokedCB (System.Object o, GLib.ClosureInvokedArgs args) <0x418a14b0 + 0x00153> in <filename unknown>:0
  at GLib.SignalClosure.Invoke (GLib.ClosureInvokedArgs args) <0x418a1470 + 0x0002f> in <filename unknown>:0
  at GLib.SignalClosure.MarshalCallback (IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data) <0x4189fe00 + 0x002bb> in <filename unknown>:0

Tags: easy-to-fix
Revision history for this message
Christian Ridderborg (chrider) wrote :

I can confirm this happens (in my case for png files - type of file should not matter though)
Steps to reproduce:
1. Open pinta as a regular user
2. Save the image to /usr/share/alsa/test.png
3. Unhandled exception is triggered:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> GLib.GException: Failed to open '/usr/share/alsa/test.png' for writing: Permission denied
  at Pinta.Actions.SaveDocumentImplmentationAction.SaveFile (Pinta.Core.Document document, System.String file, Pinta.Core.FormatDescriptor format, Gtk.Window parent) <0x4143a070 + 0x00513> in <filename unknown>:0
  at Pinta.Actions.SaveDocumentImplmentationAction.SaveFileAs (Pinta.Core.Document document) <0x41436260 + 0x00a4f> in <filename unknown>:0
  at Pinta.Actions.SaveDocumentImplmentationAction.Activated (System.Object sender, Pinta.Core.DocumentCancelEventArgs e) <0x41436130 + 0x0005b> in <filename unknown>:0
  at Pinta.Core.FileActions.RaiseSaveDocument (Pinta.Core.Document document, Boolean saveAs) <0x41435fe0 + 0x00075> in <filename unknown>:0
  at Pinta.Core.Document.Save (Boolean saveAs) <0x41435f90 + 0x00033> in <filename unknown>:0
  at Pinta.Actions.SaveDocumentAsAction.Activated (System.Object sender, System.EventArgs e) <0x41435f50 + 0x00027> in <filename unknown>:0
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) <0x7f7199dab9e0 + 0x000a1> in <filename unknown>:0

Changed in pinta:
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
grofaty (grofaty) wrote :

I tested steps from post #1 using Pinta-daily on Ubuntu 18.04. It looks like if Pinta does not have access to some directory it just crashes with "Permission denied" exception.

tags: added: easy-to-fix
Revision history for this message
grofaty (grofaty) wrote :

I did tests on Pinta 1.8-development on Ubuntu 20.04:
https://github.com/PintaProject/Pinta/actions/runs/455360743

Observations:
a) Pinta does not crashes anymore when trying to SAVE to read-only directory,
b) Pinta still crashes when trying to open read only file.

See attachment for detailed tests.

Changed in pinta:
milestone: none → 1.8
Revision history for this message
Cameron White (cameronwhite91) wrote :
Changed in pinta:
status: Confirmed → Fix Committed
Changed in pinta:
milestone: 1.8 → 1.7.1
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.

Duplicates of this bug

Other bug subscribers

Bug attachments

Remote bug watches

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