Skip to content

Commit

Permalink
ShowURL : Improve opening of "file://" URLs on Windows
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
murraystevenson committed Jul 27, 2024
1 parent 1da8fe2 commit 0a98ca3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------------
Expand Down
7 changes: 7 additions & 0 deletions python/GafferUI/ShowURL.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) )

0 comments on commit 0a98ca3

Please sign in to comment.