2 Replies
      Latest reply on Aug 14, 2019 9:37 AM by Joanna Carter
      Joanna Carter Level 1 Level 1 (0 points)

        I have an NSCollectionView, whose items contain an image which is created with QLThumbnailImageCreate.

         

        Everything was working fine until I added in the ability to preview items using QLPreviewPanel.

         

        As long as I don't invoke the QLPreviewPanel, I can reloadData() on the CollectionView without any problem but, as soon as I have invoked the QLPreviewPanel and hidden it again, calling reloadData() causes a slew of warnings to the effect of:

         

        [QL] QLError(): Asking to compute a thumbnail in main thread is potentially blocking the user interface

         

        … for every item in the collection view.

         

        Here is the code I have added to the ViewController :

         

        extension ViewController : QLPreviewPanelDataSource
        {
          public override func acceptsPreviewPanelControl(_ panel: QLPreviewPanel!) -> Bool
          {
            return true
          }
          
          public override func beginPreviewPanelControl(_ panel: QLPreviewPanel!)
          {
            panel.dataSource = self
          }
          
          override func endPreviewPanelControl(_ panel: QLPreviewPanel!)
          {
            panel.dataSource = nil
          }
        
          func numberOfPreviewItems(in panel: QLPreviewPanel!) -> Int
          {
            return selectedItems.count
          }
        
          func previewPanel(_ panel: QLPreviewPanel!, previewItemAt index: Int) -> QLPreviewItem!
          {
            return selectedItems[index].url! as QLPreviewItem
          }
        }
        

         

        All in all, this API is very poorly documented. Anyone got any ideas?