Plugins: RVF File Viewer: Viewer pane debug

I had a look at why the new RVF File Viewer doesn't open in the viewer pane.
[ul][li]What I see happening

The viewer window is created successfully (or at least DVP_CreateViewer returns a window handle which responds to a couple of messages without problems).

But when Opus then sends the DVPLUGINMSG_LOADA message to the window, with the ANSI filepath in LParam, an exception is thrown from within RVView.dll.

I've attached a screenshot of the callstack at the point of the exception in case it's useful. (See second screenshot below.)

Since the exception is coming from the viewer DLL and I don't have Delphi, that's about as far as I got, but maybe it helps track things down.
[/li]
[li]Viewer Window vs Pane differences

In terms of what might be different about the viewer pane vs the standalone viewer windows, which might be underlying the problem, the main thing which I can think of is the UI threads:

The standalone viewer window is a normal window with just one UI thread; the plugin's window will be created on the same UI thread as the top-level frame it is hosted in.

On the other hand, the viewer pane creates a separate UI thread for plugin window. Plugin windows are created on a different UI thread to their parent windows. So if you have any code which assumes that the top-level frame window is on the same UI thread as the plugin's window(s) then it will go wrong.

I've attempted to clarify which window is on which thread in the first image attached below.

The UI thread stuff may not be important but it's the only thing I can think of off the top of my head.
[/li]
[li]Debugging

The first thing I'd do try to do is find out where in the DVPLUGINMSG_LOADA handler the exception is coming from.

I'm not familiar with Delphi at all but if it's like Visual C++ then you should be able to run Opus and then attach the Debugger to dopus.exe and set a breakpoint within your plugin DLL. I do this all the time when debugging my own plugins and it works great. After I've debugged stuff I can detach the debugger, tell Opus to flush the plugins (Show FLUSHPLUGINS command) and copy a new version of the DLL into the viewers directory, all without having to restart Opus.

(BTW, Only use Show FLUSHPLUGINS for debugging... There are cases where you'll get a crash from swapping out plugin versions like that. In practice it's usually fine so long as your plugin doesn't change which functions and capabilities it implements, but it's not reliable enough to use as part of an installer or anything like that.)[/li][/ul]

Hope that helps!



Thank you, I'll test it later today.
But strange, I aready used debugger while creating this plugin, but I did not notice an exception on file loading...

Are DVP_CreateViewer and processing of DVPLUGINMSG_LOADA executed in the same thread?

Yes, they should be.

I found it. This exception occured when opening file (and was handled).
It was because the component tried to open the file in exclusive sharing mode, but it was obviously already opened by Opus.
I fixed it, updated version will be uploaded soon.

Good stuff. I tried the new version and it works great.

I put a note about the new plugin on the Opus News RSS Feed.