Crash with dynamic QLPreviewViewControlMBS

Has anyone an idea why I am getting this crash? Could it be, that the previewfile is locked or something?

I’m dynamically adding a QLPreviewViewControlMBS control to a ContainerControl. It seems to work, but when I try to assign a file for preview to it, then it crashes the app completely. The keyword in the crashlog seems to be: blockingUntilLoading, but I’m stuck with that.

[quote]4 0x02f36399 _QLCrash + 222
5 0x02f3644b _QLRaiseAssert + 178
6 0x02cf6f1b -[QLPreviewView setPreviewItem:blockingUntilLoading:timeoutDate:transition:] + 208
7 0x02cf6e45 -[QLPreviewView setPreviewItem:blockingUntilLoading:timeoutDate:] + 64
8 0x02cf6dff -[QLPreviewView setPreviewItem:blockingUntilLoading:] + 57
9 0x02cf6dc1 -[QLPreviewView setPreviewItem:] + 48
10 MBS Xojo SnowLeopard Plugin.xojo_plugin_6.dylib 0x0c367f12 setpreviewItem(REALobjectStruct*, REALfolderItemStruct*) + 354
11 0x006cca60 QLPreviewViewMBS.=previewItem%%oo + 86
The complete log could be downloaded from here:

I have a working proof-of-concept app, where I dynamically create a QLPreviewControlMBS and use it:

So in tests it works, but in my actual app it crashes.

From a XojoScript, I try to access a listbox “filebox”, get a file from it and set the file to the previewitem of the QLPreviewViewControlMBS.

Setting it to Nil does not crash:


Setting it to an existing file does crash the app:


The XojoScript context method looks like this:

[code]Protected Sub SetPreview(FileboxName As String, PreviewName As String)

Dim fb As imFilebox = WindowMain.imFB(FileboxName)
If fb = Nil Then Return

Dim pv As imPreview = WindowMain.imPR(PreviewName)
If pv = Nil Then Return

// Clear Preview

If fb.ListCount > 0 Then
Dim idx As Integer = fb.ListIndex
If idx >= 0 Then
If fb.RowTag(idx) <> Nil Then
Dim f As FolderItem = fb.RowTag(idx)
If f <> Nil And f.Exists Then
// Set preview file
pv.n.previewItem=f // <<<=== Crashes here
End If
End If
End If
End If
// …
End Try

End Sub

Thanks for reporting. Let me look.

your test project does not crash here.

The log shows this entry:

Performing @selector(performClick:) from sender XOJButton 0x14010030
abort() called
Assertion failure in -[QLPreviewView setPreviewItem:blockingUntilLoading:timeoutDate:transition:] (line 1073): item == nil || _reserved->internalState != QLPreviewDeactivatedInternalState

So the item was set to nil, but the state was not right?
Maybe the asynchronously loading got confused?

Yes, the short example is working - as I wrote above.

However, in the real world app, I’m losing the View ( QLPreviewViewMBS). I’m struggling with this already all day long. I think I go to sleep and will try tomorrow to figure out the difference between the working example and the other one…

Thanks for answering!

have a good night.

And it may not even be required to dynamically create those controls in big numbers. Often you need only one.