Skip to content

Conversation

@julien-lang
Copy link
Contributor

This PR is a temporary workaround trying to make the code compatible with Houdini 21.0+.

Important

This PR is only a workaround and we don't intend to merge it as is.
It is not designed to be used for production.

This PR is collection of merges of other PRs:

Workaround for odd behavior in Houdini 21.0+ not seeing the menu
file if created by a startup script
Remove old code handling unsupported Houdini
that was targetting Qt5 and was not Qt6-ready.

Was causing a AttributeError: function 'PyCObject_AsVoidPtr' not found
…h21.0' into ticket/SG-40114-temp-workaround-houdini-21.0
…or-h21.0' into ticket/SG-40114-temp-workaround-houdini-21.0
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a temporary workaround to address compatibility issues with Houdini 21.0+. The changes focus on fixing menu functionality and resolving Python API compatibility problems.

Key changes:

  • Adds pre-launch menu construction for Houdini 21.0+ compatibility
  • Removes deprecated PyCObject_AsVoidPtr usage that causes errors in newer Python versions
  • Simplifies Windows dialog handling to work with modern Houdini versions

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
startup.py Adds conditional menu generation logic for Houdini 21.0+ before application launch
engine.py Removes deprecated PyCObject_AsVoidPtr API calls and simplifies Windows dialog handling

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

if self.get_setting("use_short_menu_name", False):
mock_engine._menu_name = "FPTR"

import tk_houdini
Copy link

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

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

The import statement should be moved to the top of the file with other imports to follow Python best practices and improve code readability.

Copilot uses AI. Check for mistakes.
Comment on lines +139 to +146
pass

mock_engine = MockEngine()
mock_engine.logger = self.logger

mock_engine._menu_name = "Flow Production Tracking"
if self.get_setting("use_short_menu_name", False):
mock_engine._menu_name = "FPTR"
Copy link

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

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

Creating a mock engine class inline with dynamic attribute assignment is fragile. Consider defining a proper MockEngine class with init method or using a more structured approach like a namedtuple or dataclass.

Suggested change
pass
mock_engine = MockEngine()
mock_engine.logger = self.logger
mock_engine._menu_name = "Flow Production Tracking"
if self.get_setting("use_short_menu_name", False):
mock_engine._menu_name = "FPTR"
def __init__(self, logger, menu_name):
self.logger = logger
self._menu_name = menu_name
menu_name = "Flow Production Tracking"
if self.get_setting("use_short_menu_name", False):
menu_name = "FPTR"
mock_engine = MockEngine(self.logger, menu_name)

Copilot uses AI. Check for mistakes.
Comment on lines 1048 to 1049
ctypes.windll.user32.SetActiveWindow(hwnd)

Copy link

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

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

The code assumes dialog.winId() returns a valid Windows handle without validation. This could fail if winId() returns None or an invalid handle, potentially causing ctypes.windll.user32.SetActiveWindow to fail silently or raise an exception.

Suggested change
ctypes.windll.user32.SetActiveWindow(hwnd)
# Validate hwnd before using it
if hwnd is not None and int(hwnd) != 0:
ctypes.windll.user32.SetActiveWindow(hwnd)
else:
self.logger.warning(
"Could not activate dialog window: invalid winId() returned ({})".format(hwnd)
)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants