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

Fix Open Image Relative Path failing - New Try #269

Merged
merged 3 commits into from
Mar 18, 2024

Conversation

Spiderguy-F
Copy link
Contributor

@Spiderguy-F Spiderguy-F commented Feb 15, 2024

We cleaned up the chaos by creating a new branch. The behaviour should match the previous behaviour now, let's call it "intuitive".
class OpenImage(Operator)
fails when using the default 'relative_path' property (True) on Windows. Python os.path.join on Windows does not recognize '//' to be the beginning of a directory and treats it like a filename.
We fixed that error and made the file browser start where the previous image was located. We also modified the dedfault location of the File Viewer to either:
a) Start where a file was selected the last time the File View was used or:
b) if an image had been previously assigned to the target_property, the File View will start with that image selected.
This is Blender's default behaviour
grafik

It probably failed when selecting an image for a reflection probe as well and should be working everywhere now.

@Spiderguy-F Spiderguy-F changed the title Fix Open Image Relative Path failing Fix Open Image Relative Path failing - New Try Feb 15, 2024
Copy link
Contributor

@keianhzo keianhzo 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 this! Looks good to me, just a couple of nits and also there are some formatting issues, please run python ./check_style.py and fix those to keep the code format consistency.

def draw(self, context):
layout = self.layout

def draw(self, context): #this def is obsolete, bc. target_property is hidden by default now and relative_path is displayed by default anyways
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this is not required anymore in any of the supported Blender versions, I think we can safely remove it.

def execute(self, context):
dirname = os.path.dirname(self.filepath)

#dirname = os.path.dirname(self.filepath) #dirname fails if path selected in the Blender File View is relative (starts with //) on Windows
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment can be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done
check_style finds a few issues in other files as well, want me to fix that?

@keianhzo
Copy link
Contributor

Thanks perfect, thanks!

@keianhzo keianhzo merged commit 85e0d0b into Hubs-Foundation:master Mar 18, 2024
6 checks passed
@GottfriedHofmann GottfriedHofmann deleted the OpenImageFix branch March 18, 2024 16:39
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.

2 participants