Page 1 of 1

[sugg/BUG?] NCONVERT plugin management: make it fool proof

Posted: Sun Mar 06, 2011 1:50 pm
by DOS386
(as started in messy thread: http://newsgroup.xnview.com/viewtopic.php?t=21685)

Problem: plugin management in NC is not very user friendly and fool-proof (+ possibly even buggy).

- Plugins are not accepted in same directory as NC
- It says "Error: Don't know how to read this picture" ... but better message would be "This format needs the plugin" (name) or "Plugin" (name) "failed" (additionally at startup: "Plugin" (name) "DLL load/init failed" or "NOT found")
- Loads same plugin 2 times (5.85: before and after opening the input file) (or even more is possible?) ??? Tries even wrong plugins (5.80) ...
- Very hard to debug, verbose option says nothing about attempts to find or use plugins

So I invented following (pseudo-code) to fix this (run at NC start, before opening any input files):

Code: Select all

X0 = GetFileAttributes ("PLUGINS")
IF (X0 says "exists and is a DIRECTORY") THEN
    PluginSearchPath="PLUGINS\" // The old known behavior 
ELSE
    PluginSearchPath="" // Look in the same directory
ENDIF
PluginIndex := 0
DO
    IF (PluginIndex says "no more plugins") THEN EXIT
    PluginName = ArrayOfPluginNames (PluginIndex)
    PluginMoHaArray (PluginIndex) := 0 // NOT available
    S1 = PluginSearchPath + PluginName + ".DLL"
    IF ("verbose") THEN PRINT "Plugin: " + S1 + " ... "
    X2 = GetFileAttributes (S1)
    IF (X2 says "exists and is a file") THEN
        X3 = LoadLibrary (S1)
        IF (X3 == "success") THEN
            PluginMoHaArray (PluginIndex) := X3 // Save Module Handle
            IF ("verbose") THEN PRINT "Loaded OK"
        ELSE
            IF ("verbose") THEN PRINT "DLL load/init failed" 
            // Most ^^^ likely some stupid 4th party DLL like
            // MSVCxxxx was not found or has wrong version :-(
        ENDIF (X3 == "success") // LoadLibrary result
    ELSE // plugin file existence
        IF ("verbose") THEN PRINT "NOT found"
    ENDIF // plugin file existence
    INC (PluginIndex)
    IF ("verbose") THEN PRINT (EOL)
LOOP
Later, when processing files, return (even if not verbose):

- "Error: Don't know how to read this picture" only if no plugin exists to handle it
- "This format needs the plugin" (name) if plugin could help, but (PluginMoHaArray (PluginIndex) == 0)
- "Plugin" (name) "failed" if plugin returned failure or GetProcAddress return "NOT found" for needed function

Example output:

---------------------------
Plugin: "webp.dll" ... Loaded OK
Plugin: "CADImage.DLL" ... NOT found
Plugin: "CS_DXF.DLL" ... NOT found
Plugin: "lwf.dll" ... NOT found
Plugin: "ldf.dll" ... DLL load/init failed
or
Plugin: "PLUGINS\webp.dll" ... Loaded OK
Plugin: "PLUGINS\CADImage.DLL" ... Loaded OK
Plugin: "PLUGINS\CS_DXF.DLL" ... Loaded OK
Plugin: "PLUGINS\lwf.dll" ... Loaded OK
Plugin: "PLUGINS\ldf.dll" ... Loaded OK
---------------------------
This format needs the plugin "WEBP.DLL"
or
Plugin "WEBP.DLL" failed
---------------------------

Re: [sugg/BUG?] NCONVERT plugin management: make it fool pro

Posted: Mon Mar 07, 2011 8:13 am
by xnview
DOS386 wrote: - Plugins are not accepted in same directory as NC
Nconvert use Plugin folder, not for you??
- Loads same plugin 2 times (5.85: before and after opening the input file) (or even more is possible?) ??? Tries even wrong plugins (5.80) ...
With which command?

Re: [sugg/BUG?] NCONVERT plugin management: make it fool pro

Posted: Tue Mar 08, 2011 3:50 am
by DOS386
xnview wrote:Nconvert use Plugin folder, not for you??
I had it in my tests ... but allowing to place plugins into same directory too would be an improvement. :-)
With which command?
I don't have it for sure (yet) ... I see the strings only ("Plugins\webp.dll" and "msvcr90.dll") ... so I suspect LoadLibrary as it re-resolves "msvcr90.dll" :?

Re: [sugg/BUG?] NCONVERT plugin management: make it fool pro

Posted: Thu Sep 08, 2011 7:53 am
by salma66
Are there any news on the topic by now? :?:
JMK Design

Re: [sugg/BUG?] NCONVERT plugin management: make it fool pro

Posted: Fri Sep 09, 2011 10:07 am
by DOS386
salma66 wrote:Are there any news on the topic by now? :?:
Heh, someone answered ;-)