Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GafferDelight : Import IECoreDelight on Windows #5082

Merged
merged 1 commit into from
Jan 20, 2023

Conversation

ericmehl
Copy link
Collaborator

GafferDelight does not need any symbols from IECoreDelight, so MSVC tries to be helpful and not load IECoreDelight.dll. Skipping that means that 3Delight is never registered as a renderer, so we import / register it manually.

This was causing errors loading the UI because GafferDelight was not throwing an exception when it was expected to. It also caused Gaffer to crash when trying to render with 3delight.

Fixes #5081

Checklist

  • I have read the contribution guidelines.
  • I have updated the documentation, if applicable.
  • I have tested my change(s) in the test suite, and added new test cases where necessary.
  • My code follows the Gaffer project's prevailing coding style and conventions.

Copy link
Member

@johnhaddon johnhaddon left a comment

Choose a reason for hiding this comment

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

Thanks for getting to the bottom of this one so quickly Eric. In addition to the inline comments, we also need to update Changes.md so that the release notes for 1.2.0.0a3 will mention the fix.

Comment on lines 41 to 56
# GafferDelight does not need any symbols from IECoreDelight, so MSVC tries
# to be helpful and not load IECoreDelight.dll. Skipping that means that
# 3Delight is never registered as a renderer, so we import / register it manually.

import os

ieCoreDelight = None

if os.name == "nt" and ieCoreDelight is None :

import ctypes

try :
ieCoreDelight = ctypes.CDLL( "IECoreDelight.dll" )
except :
raise ImportError
Copy link
Member

Choose a reason for hiding this comment

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

In #5040, you mentioned that the IECoreDelight module had this same problem, so I think perhaps it would be best to put the fix in IECoreDelight/__init__.py instead? I presume that would be necessary to get the IECoreDelightTest module passing. Then we could just __import__( IECoreDelight ) at the top of this file, so the same fix works for GafferDelight.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, that's definitely a better solution. Fixed in e95e2f3


import os

ieCoreDelight = None
Copy link
Member

Choose a reason for hiding this comment

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

This variable seems to be unused (other than to be assigned again at L54) - do we really need it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I also use it to on L49 to check that we haven't already imported IECoreDelight.dll. I think that was left over from a debugging effort though. I don't think there's much harm in asking for an already loaded library to be loaded.

Copy link
Member

Choose a reason for hiding this comment

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

Is it possible for it to be set True between L47 and L49 though?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ahhhhhh, right. Don't mind me. 🗿 Fixed in e95e2f3

The IECoreDelight module does not need any symbols from IECoreDelight,
so MSVC tries to be helpful and not load IECoreDelight.dll. Skipping
that means that 3Delight is never registered as a renderer, so we
import / register it manually.
@ericmehl ericmehl force-pushed the gafferDelight-Windows-fix branch from b3215a4 to e95e2f3 Compare January 19, 2023 15:16
@ericmehl
Copy link
Collaborator Author

I have the two comments fixed up, ready for another review as long as CI succeeds.

@johnhaddon johnhaddon merged commit a1b6888 into GafferHQ:main Jan 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3Delight interactive render crash
2 participants