On 05.09.2012, at 10:37, "MacArthur, Ian (SELEX GALILEO, UK)" 
<[email protected]> wrote:

> 
>>      FLTKInstance = GetModuleHandle("fltkdll.dll");  //access count is N
>> (assumed > 0)
>>      while (FLTKInstance)
>>      {
>>              BOOL fi = FreeLibrary(FLTKInstance);
>>              if (fi) FLTKInstance = GetModuleHandle("fltkdll.dll");
>>              else    FLTKInstance = NULL;
>>      }
>>      //completely unloaded now.
>>      FLTKInstance = LoadLibrary("fltkdll.dll");              //
>>      //we get to here, and the DLL is loaded, but it doesn't matter. No UI
>> will come up the second time
> 
> 
> I wonder if we need to explicitly unregister the fltk window classes from the 
> Windows context and then re-assert them, or maybe register them with a 
> different name each time, or something...?


I am not sure if the entire endeavor will ever work. It's a long time ago that 
I used the PS plugin API, and it was quite limiting. I believe that there is a 
good reason for that: it is close to impossible to have independent UI systems 
running within one application. 

Even though FLTK is of course based on the same core libraries as Photoshop, 
there can be only on master. This master captures all the events sent from the 
OS and decides if they are sent on or not. FLTK requires a lot of events to 
function correctly, but if Photoshop snaps those events away before they reach 
FLTK, FLTK will never function correctly.

My approach would be to separate the math and the UI into two processes - not 
just threads, but independent programs. This sounds like a lot of work, but it 
doesn't have to be. There are tons of APIs out there that make interprocess 
communication less of a pain.

For example, you can use a simple pipe to send commands back and forth. You can 
use file mapping or shared memory to quickly exchange image data for previews, 
and much more. 

I know, this adds a layer of complexity, but depending on how you write your 
app and filter, you can use this separation as a benefit, for example:
- offer a filter without a UI as a cheaper support tool without giving away the 
full functionality
- have a standalone version with the UI only, so you can sell to users without 
photoshop

Missing re-initialization should not be a problem IMHO because no resources 
have been freed either. At the next call of you plugin, you should be able to 
simply continue where you left off, minus the limitations in the event loop, as 
describe above (note; opening a window also uses and causes events, meaning 
that a limited event loop may make it impossible to open windows!).


- Matthias
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to