After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 596912 - NRE when moving pages
NRE when moving pages
Status: RESOLVED FIXED
Product: pdfmod
Classification: Other
Component: general
git master
Other Linux
: Normal major
: ---
Assigned To: pdfmod-maint
pdfmod-maint
Depends on:
Blocks:
 
 
Reported: 2009-09-30 20:25 UTC by Robert Dyer
Modified: 2010-03-27 02:04 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to fix it (915 bytes, patch)
2009-09-30 20:25 UTC, Robert Dyer
committed Details | Review

Description Robert Dyer 2009-09-30 20:25:17 UTC
Received the following exception:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object
  at PdfSharp.Pdf.PdfPage..ctor (PdfSharp.Pdf.PdfDocument document) [0x00042] in /home/rdyer/pdfmod/lib/PdfSharp/PdfSharp.Pdf/PdfPage.cs:75 
  at PdfSharp.Pdf.PdfPages.ImportExternalPage (PdfSharp.Pdf.PdfPage importPage) [0x0001c] in /home/rdyer/pdfmod/lib/PdfSharp/PdfSharp.Pdf/PdfPages.cs:219 
  at PdfSharp.Pdf.PdfPages.Insert (Int32 index, PdfSharp.Pdf.PdfPage page) [0x00106] in /home/rdyer/pdfmod/lib/PdfSharp/PdfSharp.Pdf/PdfPages.cs:160 
  at PdfMod.Pdf.Document.Add (Int32 to_index, PdfMod.Pdf.Page[] add_pages) [0x00014] in /home/rdyer/pdfmod/src/PdfMod/Pdf/Document.cs:304 
  at PdfMod.Pdf.Document.AddFromUri (System.Uri uri, Int32 to_index, System.Int32[] pages_to_import) [0x00071] in /home/rdyer/pdfmod/src/PdfMod/Pdf/Document.cs:295 
  at PdfMod.Gui.DocumentIconView.HandleDragDataReceived (System.Object o, Gtk.DragDataReceivedArgs args) [0x00175] in /home/rdyer/pdfmod/src/PdfMod/Gui/DocumentIconView.cs:337 
  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] 
  --- 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] 
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] 
  at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x00000] 
  at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x00000] 
  at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] 
  at GLib.Signal.ClosureInvokedCB (System.Object o, GLib.ClosureInvokedArgs args) [0x00000] 
  at GLib.SignalClosure.Invoke (GLib.ClosureInvokedArgs args) [0x00000] 
  at GLib.SignalClosure.MarshalCallback (IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data) [0x00000] 
   at GLib.ExceptionManager.RaiseUnhandledException(System.Exception e, Boolean is_terminal)
   at GLib.SignalClosure.MarshalCallback(IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data)
   at Gtk.Application.gtk_main()
   at Gtk.Application.Run()
   at PdfMod.Gui.Client..ctor(Boolean loadFiles) in /home/rdyer/pdfmod/src/PdfMod/Gui/Client.cs:line 136
   at PdfMod.PdfMod.Main(System.String[] args) in /home/rdyer/pdfmod/src/PdfMod/Main.cs:line 39

This happened when I attempted to move a page (any page).
Comment 1 Robert Dyer 2009-09-30 20:25:37 UTC
Created attachment 144439 [details] [review]
Patch to fix it
Comment 2 Gabriel Burt 2009-10-01 02:12:42 UTC
So is your CurrentRegion sometimes null and sometimes not?
Comment 3 muhr 2009-11-15 12:10:13 UTC
(In reply to comment #2)
> So is your CurrentRegion sometimes null and sometimes not?

I can confirm this. On my machine, CurrentRegion always returns null and makes PdfMod crash (also with other operations such as extracting pages).

Regarding the patch of Robert Dyer: it does not catch all instances where PdfSharp relies on CurrentRegion being not null.
Comment 4 Robert Dyer 2009-11-15 12:12:24 UTC
Correct, I only patched the point where it crashes for me. :-)

The better question is why is CurrentRegion null, and is this allowed or should there be a bug report filed upstream?
Comment 5 muhr 2009-11-15 15:06:52 UTC
(In reply to comment #4)
> Correct, I only patched the point where it crashes for me. :-)
> 
> The better question is why is CurrentRegion null, and is this allowed or should
> there be a bug report filed upstream?

I've been looking a bit into this. The docs at MSDN are not conclusive as to whether CurrentRegion is allowed to return null or not. I've also had a look at the rotor sources. They seem to never return null. So should this be reported to the Mono guys?
Comment 6 Gabriel Burt 2009-11-17 18:17:23 UTC
I've asked for an opinion on this at https://bugzilla.novell.com/show_bug.cgi?id=417832
Comment 7 Gabriel Burt 2010-03-27 02:03:57 UTC
Sorry, should have committed this workaround/fix in the mean time; done; thanks for the patch!