GNOME Bugzilla – Bug 596912
NRE when moving pages
Last modified: 2010-03-27 02:04:32 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).
Created attachment 144439 [details] [review] Patch to fix it
So is your CurrentRegion sometimes null and sometimes not?
(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.
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?
(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?
I've asked for an opinion on this at https://bugzilla.novell.com/show_bug.cgi?id=417832
Sorry, should have committed this workaround/fix in the mean time; done; thanks for the patch!