an exception raised when creating a new image with width 0px and height 0px.

Bug #776307 reported by bruce on 2011-05-03
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Pinta
Medium
Cameron White

Bug Description

exception information follows:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.DivideByZeroException: Division by zero
  at Pinta.Core.DocumentWorkspace.set_Scale (Double value) [0x00000] in <filename unknown>:0
  at Pinta.Core.WorkspaceManager.set_Scale (Double value) [0x00000] in <filename unknown>:0
  at Pinta.Core.ViewActions.UpdateCanvasScale () [0x00000] in <filename unknown>:0
  at Pinta.Core.DocumentWorkspace.ZoomAndRecenterView (ZoomType zoomType, PointD point) [0x00000] in <filename unknown>:0
  at Pinta.Core.DocumentWorkspace.ZoomManually () [0x00000] in <filename unknown>:0
  at Pinta.Core.ViewActions.HandlePintaCoreActionsViewZoomComboBoxComboBoxChanged (System.Object sender, System.EventArgs e) [0x00000] in <filename unknown>:0
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (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) [0x00000] 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) [0x00000] in <filename unknown>:0
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0
  at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x00000] in <filename unknown>:0
  at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x00000] in <filename unknown>:0
  at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in <filename unknown>:0
  at GLib.Signal.ClosureInvokedCB (System.Object o, GLib.ClosureInvokedArgs args) [0x00000] in <filename unknown>:0
  at GLib.SignalClosure.Invoke (GLib.ClosureInvokedArgs args) [0x00000] 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) [0x00000] in <filename unknown>:0

this exception exists in the pinta for windows xp version.

bruce (bruce-oy) wrote :
bruce (bruce-oy) on 2011-05-03
description: updated
grofaty (grofaty) wrote :

Hi,
please write your Pinta version from Help | About menu?

Can you also please write step-by-step instruction how to reproduce this problem?
Regards

grofaty (grofaty) wrote :

Oh, now I have seen the bug title...

Reproduce scenario (Pinta 1.0 on Windows XP):
1. Open Pinta.
2. Click New button from toolbar.
3. In "New Image" window in both fields Width and Height type in: 0
4. Click on OK button.

Yes, it is strange to have a picture with zero size, don't know what bruce would like to accomplish, but I think program should NEVER crash despite of using non-logical values.

I have also tried to insert negative number, but leaving the current field it changes value to 0. Maybe the solution should be to revert to 1 for all values that are equal or lover then zero.

grofaty (grofaty) wrote :

I have also tried to create the opposite of this bug report, to create a picture as big as possible. I have created a new bug 776346 report because I get different error messages. But probably limiting upper and lower image size is the solution for both bug reports.

Download full text (3.5 KiB)

creating an image with 0px width and 0px height is meaningless. but as you
said, a program should validate user's input and avoid crashing.

why i want to create an image with 0px width and 0px height ? because i have
copied an image into my clipboard. i expect the canvas will autosize to the
actual size of the image when i click ctrl+v in pinta.

so i request a new practical feature:
when open the new image window, the actural size of the image in the
clipboard will be detected.

2011/5/3 grofaty <email address hidden>

> I have also tried to create the opposite of this bug report, to create a
> picture as big as possible. I have created a new bug 776346 report
> because I get different error messages. But probably limiting upper and
> lower image size is the solution for both bug reports.
>
> --
> You received this bug notification because you are a direct subscriber
> of the bug.
> https://bugs.launchpad.net/bugs/776307
>
> Title:
> an exception raised when creating a new image with width 0px and
> height 0px.
>
> Status in Pinta:
> New
>
> Bug description:
> exception information follows:
> System.Reflection.TargetInvocationException: Exception has been thrown by
> the target of an invocation. ---> System.DivideByZeroException: Division by
> zero
> at Pinta.Core.DocumentWorkspace.set_Scale (Double value) [0x00000] in
> <filename unknown>:0
> at Pinta.Core.WorkspaceManager.set_Scale (Double value) [0x00000] in
> <filename unknown>:0
> at Pinta.Core.ViewActions.UpdateCanvasScale () [0x00000] in <filename
> unknown>:0
> at Pinta.Core.DocumentWorkspace.ZoomAndRecenterView (ZoomType zoomType,
> PointD point) [0x00000] in <filename unknown>:0
> at Pinta.Core.DocumentWorkspace.ZoomManually () [0x00000] in <filename
> unknown>:0
> at
> Pinta.Core.ViewActions.HandlePintaCoreActionsViewZoomComboBoxComboBoxChanged
> (System.Object sender, System.EventArgs e) [0x00000] in <filename unknown>:0
> at (wrapper managed-to-native)
> System.Reflection.MonoMethod:InternalInvoke
> (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) [0x00000] 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) [0x00000] in <filename unknown>:0
> at System.Reflection.MethodBase.Invoke (System.Object obj,
> System.Object[] parameters) [0x00000] in <filename unknown>:0
> at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x00000] in
> <filename unknown>:0
> at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args)
> [0x00000] in <filename unknown>:0
> at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in
> <filename unknown>:0
> at GLib.Signal.ClosureInvokedCB (System.Object o,
> GLib.ClosureInvokedArgs args) [0x00000] in <filename unknown>:0
> at GLib.SignalClosure.Invoke (GLib.ClosureInvokedArgs args) [0x00000...

Read more...

grofaty (grofaty) wrote :

If you would like to paste the picture from clipboard and get a auto-size the canvas then use alt+ctrl+v or use Edit | Paste Into New Image option. You don't need to create an empty file before pasting into new image, it is automatically created.

bruce (bruce-oy) wrote :

pasting into new image works! thanks for your reply!

2011/5/4 grofaty <email address hidden>

> If you would like to paste the picture from clipboard and get a auto-
> size the canvas then use alt+ctrl+v or use Edit | Paste Into New Image
> option. You don't need to create an empty file before pasting into new
> image, it is automatically created.
>
> --
> You received this bug notification because you are a direct subscriber
> of the bug.
> https://bugs.launchpad.net/bugs/776307
>
> Title:
> an exception raised when creating a new image with width 0px and
> height 0px.
>
> Status in Pinta:
> New
>
> Bug description:
> exception information follows:
> System.Reflection.TargetInvocationException: Exception has been thrown by
> the target of an invocation. ---> System.DivideByZeroException: Division by
> zero
> at Pinta.Core.DocumentWorkspace.set_Scale (Double value) [0x00000] in
> <filename unknown>:0
> at Pinta.Core.WorkspaceManager.set_Scale (Double value) [0x00000] in
> <filename unknown>:0
> at Pinta.Core.ViewActions.UpdateCanvasScale () [0x00000] in <filename
> unknown>:0
> at Pinta.Core.DocumentWorkspace.ZoomAndRecenterView (ZoomType zoomType,
> PointD point) [0x00000] in <filename unknown>:0
> at Pinta.Core.DocumentWorkspace.ZoomManually () [0x00000] in <filename
> unknown>:0
> at
> Pinta.Core.ViewActions.HandlePintaCoreActionsViewZoomComboBoxComboBoxChanged
> (System.Object sender, System.EventArgs e) [0x00000] in <filename unknown>:0
> at (wrapper managed-to-native)
> System.Reflection.MonoMethod:InternalInvoke
> (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) [0x00000] 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) [0x00000] in <filename unknown>:0
> at System.Reflection.MethodBase.Invoke (System.Object obj,
> System.Object[] parameters) [0x00000] in <filename unknown>:0
> at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x00000] in
> <filename unknown>:0
> at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args)
> [0x00000] in <filename unknown>:0
> at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in
> <filename unknown>:0
> at GLib.Signal.ClosureInvokedCB (System.Object o,
> GLib.ClosureInvokedArgs args) [0x00000] in <filename unknown>:0
> at GLib.SignalClosure.Invoke (GLib.ClosureInvokedArgs args) [0x00000] 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) [0x00000] in <filename unknown>:0
>
> this exception exists in the pinta for windows xp version.
>
> To unsubscribe from this bug, go to:
> https://bugs.launchpad.net/pinta/+bug/776307/+subscribe
>

Robert Nordan (rpvn) wrote :

Cameroan White made an attempt at fixing this that was committed, but I'm afraid the change wasn't enough to fix the entire problem. I just checked with a fresh build from source and you still get an unhandled exception from entering 0 x 0.

Changed in pinta:
assignee: nobody → Cameron White (cameronwhite91)
status: New → Triaged
importance: Undecided → Medium
Cameron White (cameronwhite91) wrote :

Fixed: https://github.com/PintaProject/Pinta/commit/53cb8679a9157c39fa4272af16976fc3e1701a77

It turned out that I needed to commit the generated NewImageDialog.cs file, since it only gets generated when compiling via MonoDevelop

Changed in pinta:
status: Triaged → Fix Committed
grofaty (grofaty) wrote :

Tested on Pinta 1.1 on Windows XP sp3. Both of the problems solved:
1. New image width x height set to 0 x 0 is now set to 1 x 1.
2. If new image is pasted into existing canvas that is too small to handle the new image a question is raised if you would like to resize canvas. There is also a work-around for this problem - pasting in new image with <Ctrl>+<Alt>+V as described in #6.

Changed in pinta:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers