Skip to content

System.ArgumentException (Invalid Parameter) when switching away from a loading PPTX file #1892

@TheUHO

Description

@TheUHO

For all's convenience, please use English to fill this issue.

Please search within existing issues before the submission. Has this issue already been reported?

Describe the bug
The OfficeViewer plugin throws a System.ArgumentException when the user switches to a different file while a large .pptx file is still loading and converting. The exception occurs because the delayed UI rendering task attempts to execute after the viewer control has been hidden or removed, resulting in an invalid rendering dimension (width/height = 0) being passed to System.Drawing.Bitmap.

To Reproduce
Steps to reproduce the behavior:

  1. Select a large .pptx file (e.g., >10MB) to preview it via QuickLook.
  2. While the file is still loading/converting (before the actual preview is rendered), quickly switch to preview another file (e.g., using arrow keys).
  3. The background conversion of the initial .pptx file finishes and triggers the delayed Dispatcher.BeginInvoke rendering task.
  4. See error in the exception log due to invalid UI control dimensions.

Expected behavior
The plugin should gracefully handle rapid file switching. It should either cancel the background .pptx to .pdf conversion process when the user selects a different file, or add a safety check before rendering to ensure the viewer control's dimensions are valid (width > 0 and height > 0), rather than throwing an unhandled exception.

Desktop (please complete the following information):

  • OS Version: Windows 11 25H2
  • QuickLook Version: 4.4.0.0

Screenshots and Exception Log

QuickLook - 目标幻灯片.pptx v4.4.0.0
2026/3/15 15:00:02 Windows 10.0.26200.2

System.ArgumentException: 参数无效。
   在 System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)
   在 PdfiumViewer.PdfDocument.Render(Int32 page, Int32 width, Int32 height, Single dpiX, Single dpiY, PdfRotation rotate, PdfRenderFlags flags, Boolean drawFormFields)
   在 QuickLook.Plugin.PDFViewer.PdfPageExtension.Render(PdfDocumentWrapper doc, Int32 page, Double factor, Boolean fixDpi)
   在 QuickLook.Plugin.PDFViewer.PdfViewerControl.ReRenderCurrentPage()
   在 QuickLook.Plugin.PDFViewer.PdfViewerControl.UpdatePageViewWhenSelectionChanged(Object sender, SelectionChangedEventArgs e)
   在 System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   在 System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   在 System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   在 System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   在 System.Windows.Controls.ListBox.OnSelectionChanged(SelectionChangedEventArgs e)
   在 System.Windows.Controls.Primitives.Selector.SelectionChanger.End()
   在 System.Windows.Controls.Primitives.Selector.SelectionChanger.SelectJustThisItem(ItemInfo info, Boolean assumeInItemsCollection)
   在 System.Windows.Controls.Primitives.Selector.OnSelectedIndexChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   在 System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   在 System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   在 System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   在 System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   在 System.Windows.DependencyObject.CoerceValue(DependencyProperty dp)
   在 System.Windows.Controls.Primitives.Selector.OnItemsChanged(NotifyCollectionChangedEventArgs e)
   在 System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
   在 System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
   在 System.Windows.WeakEventManager.ListenerList`1.DeliverEvent(Object sender, EventArgs e, Type managerType)
   在 System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
   在 System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
   在 System.Windows.Data.ListCollectionView.ProcessCollectionChangedWithAdjustedIndex(NotifyCollectionChangedEventArgs args, Int32 adjustedOldIndex, Int32 adjustedNewIndex)
   在 System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   在 System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
   在 QuickLook.Common.ExtensionMethods.EnumerableExtensions.ForEach[T](IEnumerable`1 enumeration, Action`1 action)
   在 QuickLook.Plugin.OfficeViewer.SyncfusionControl.<>c__DisplayClass3_0.<OpenPowerpoint>b__0()
   在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   在 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions