From 3a0507abc80fe5dca770a9b79250cc128c92f262 Mon Sep 17 00:00:00 2001 From: Murray Stevenson <50844517+murraystevenson@users.noreply.github.com> Date: Fri, 26 Jul 2024 20:46:45 -0700 Subject: [PATCH] ShowURL : Improve opening of "file://" URLs on Windows Windows security appears to block us from opening "file://" URLs so instead we just open the file path directly, which Windows seems entirely OK with... Fixes #5861. --- Changes.md | 1 + python/GafferUI/ShowURL.py | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/Changes.md b/Changes.md index 279feaeede5..0b2943c5b2d 100644 --- a/Changes.md +++ b/Changes.md @@ -11,6 +11,7 @@ Fixes - Arnold : Fixed bug preventing UI metadata for Imagers from being loaded for Arnold 7.3. - WidgetAlgo : Fixed issue preventing `grab()` from capturing popup menus on Windows. +- ShowURL : Fixed opening of "file://" URLs on Windows (#5861). Documentation ------------- diff --git a/python/GafferUI/ShowURL.py b/python/GafferUI/ShowURL.py index 1b65d204cd5..f75249887d4 100644 --- a/python/GafferUI/ShowURL.py +++ b/python/GafferUI/ShowURL.py @@ -55,4 +55,11 @@ def showURL( url ) : if opener : os.system( "{0} \"{1}\"".format( opener, url ) ) else : + if sys.platform == "win32" and url.startswith( "file://" ) : + # Windows doesn't let us reliably open "file://" URLs but + # yet has no problem with opening the file itself. This + # means we can't support anchors in file URLs on Windows + # as we need to strip them to produce a valid file path. + url = url[7:].partition( "#" )[0] + QtGui.QDesktopServices.openUrl( QtCore.QUrl( url, QtCore.QUrl.TolerantMode ) )