From 0a98ca357b5d2e4c56547e9e4a1ccb999d39e781 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 7e5ff69f57c..60718259e5f 100644 --- a/Changes.md +++ b/Changes.md @@ -5,6 +5,7 @@ Fixes ----- - 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 ) )