Skip to content

BUG: Use SetAutoloadPath in IOPlugin example - #7029

Merged
blowekamp merged 1 commit into
InsightSoftwareConsortium:mainfrom
blowekamp:bug-ioplugin-setautoloadpath
Oct 29, 2026
Merged

blowekamp merged 1 commit into
InsightSoftwareConsortium:mainfrom
blowekamp:bug-ioplugin-setautoloadpath

Conversation

@blowekamp

Copy link
Copy Markdown
Member

Fix ExampleIOPluginTest2: switch Examples/IO/IOPlugin.cxx from putenv() + ReHash() to ObjectFactoryBase::SetAutoloadPath(), matching the API introduced in 3d301f7.

Root cause

Since 3d301f7, ReHash() reuses the autoload path cached in ObjectFactoryBase's globals instead of re-reading ITK_AUTOLOAD_PATH from the environment. IOPlugin.cxx still set the env var at runtime via putenv(), so the plugin directory passed on the command line was silently ignored, and ExampleIOPluginTest2 failed with "Could not create IO object for reading file FileFreeIO::...".

AI assistance
  • Tool: Claude Code (claude-sonnet-5)
  • Role: root-cause analysis of the test failure and the fix
  • Contribution: traced the failure to the cached autoload path introduced in 3d301f7 and updated IOPlugin.cxx to use SetAutoloadPath(), mirroring itkObjectFactoryTest2.cxx
  • Verified locally: built IOPlugin and ran ExampleIOPluginTest/ExampleIOPluginTest2 in an existing shared build; both pass

@github-actions github-actions Bot added type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances area:Examples Demonstration of the use of classes labels Oct 28, 2026
Comment thread Examples/IO/IOPlugin.cxx
{
#if defined(_WIN32)
myenv += std::string(oldenv) + ";";
path += ";";

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This system dependent issue that was inherited from the env, raises the questions if the interface source be accepting a something higher level than a string with a system dependent separator. A list of string, or an even hight level list of "path" objects might be better.

@blowekamp blowekamp Oct 30, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, a list of paths avoids baking the platform-specific separator into caller code. Done in #7035.

@dzenanz dzenanz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good on a glance.

ReHash() no longer re-reads ITK_AUTOLOAD_PATH from the environment
after 3d301f7, so putenv() + ReHash() silently loaded no plugin.
Switch to ObjectFactoryBase::SetAutoloadPath(), matching
itkObjectFactoryTest2.
@hjmjohnson
hjmjohnson force-pushed the bug-ioplugin-setautoloadpath branch from 7f1eabb to 7782740 Compare October 29, 2026 00:47
@hjmjohnson

Copy link
Copy Markdown
Member

Rebased on main (plain rebase, patch unchanged) to pick up #7028, which fixes the itkIndent.h include-cycle error behind the ARMBUILD failure. Pull with git pull --rebase before pushing again.

@blowekamp
blowekamp marked this pull request as ready for review October 29, 2026 12:26
@blowekamp
blowekamp merged commit 27d36ab into InsightSoftwareConsortium:main Oct 29, 2026
18 of 20 checks passed
@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge.

Summary

Updates IOPlugin.cxx to set the stored plugin search path through ObjectFactoryBase::SetAutoloadPath() before calling ReHash().

  • The IO plugin example finds factories in its optional folder.

Reviews (1) · Last reviewed commit: "BUG: Use SetAutoloadPath in IOPlugin exa..." · Reviewed by Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Examples Demonstration of the use of classes type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants