From 3942260e68111c2e15e57a7fc928a17d0a1a17a5 Mon Sep 17 00:00:00 2001 From: parg Date: Mon, 25 Nov 2024 11:44:49 +0000 Subject: [PATCH] Try to ensure filter path path is responding when setting on dialog --- uis/src/com/biglybt/ui/swt/Utils.java | 33 +++++++++++++++++++ .../opentorrent/OpenTorrentOptionsWindow.java | 17 ++++++---- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/uis/src/com/biglybt/ui/swt/Utils.java b/uis/src/com/biglybt/ui/swt/Utils.java index e955d63e242..147d93360f4 100644 --- a/uis/src/com/biglybt/ui/swt/Utils.java +++ b/uis/src/com/biglybt/ui/swt/Utils.java @@ -7138,6 +7138,39 @@ public void handleEvent(Event e) { terminated(); } + public static void + setFilterPathWithTimeout( + FileDialog dialog, + String path ) + { + try{ + path = FileUtil.getCanonicalPathWithTimeout( FileUtil.newFile( path ), 20*1000 ); + + dialog.setFilterPath( path ); + + }catch( Throwable e ){ + + Debug.out( "Failed to set filter path '" + path + "'" ); + } + } + + public static void + setFilterPathWithTimeout( + DirectoryDialog dialog, + String path ) + { + try{ + path = FileUtil.getCanonicalPathWithTimeout( FileUtil.newFile( path ), 20*1000 ); + + dialog.setFilterPath( path ); + + }catch( Throwable e ){ + + Debug.out( "Failed to set filter path '" + path + "'" ); + } + } + + public static boolean fileExistsWithTimeout( String path ) diff --git a/uis/src/com/biglybt/ui/swt/shells/opentorrent/OpenTorrentOptionsWindow.java b/uis/src/com/biglybt/ui/swt/shells/opentorrent/OpenTorrentOptionsWindow.java index 8818936c200..196314d1653 100644 --- a/uis/src/com/biglybt/ui/swt/shells/opentorrent/OpenTorrentOptionsWindow.java +++ b/uis/src/com/biglybt/ui/swt/shells/opentorrent/OpenTorrentOptionsWindow.java @@ -5147,7 +5147,9 @@ public void pressed(SWTSkinButtonUtility buttonUtility, DirectoryDialog dDialog = new DirectoryDialog(cmbDataDir.getShell(), SWT.SYSTEM_MODAL); - dDialog.setFilterPath(f.getAbsolutePath()); + + Utils.setFilterPathWithTimeout( dDialog, f.getAbsolutePath() ); + dDialog.setMessage(MessageText.getString("MainWindow.dialog.choose.savepath_forallfiles")); sSavePath = dDialog.open(); @@ -5447,7 +5449,7 @@ public void handleEvent(Event arg0){ String filter_path = TorrentOpener.getFilterPathData(); - dd.setFilterPath(filter_path); + Utils.setFilterPathWithTimeout( dd, filter_path ); dd.setText(MessageText.getString("MyTorrentsView.menu.movedata.dialog")); @@ -6948,7 +6950,9 @@ public void UIInputReceiverClosed(UIInputReceiver receiver) { if ( !filterPath.exists()){ filterPath = filterPath.getParentFile(); } - dDialog.setFilterPath( filterPath.getAbsolutePath()); + + Utils.setFilterPathWithTimeout( dDialog, filterPath.getAbsolutePath() ); + dDialog.setMessage(MessageText.getString("MainWindow.dialog.choose.savepath") + " (" + torrentOptions.getTorrentName() + ")"); String sNewDir = dDialog.open(); @@ -7142,7 +7146,7 @@ private void changeFileDestination(TorrentOpenFileOptions[] infos, boolean allAt if ( current_parent.length() > 0 ){ - dDialog.setFilterPath( current_parent ); + Utils.setFilterPathWithTimeout( dDialog, current_parent ); } dDialog.setMessage(MessageText.getString("MainWindow.dialog.choose.savepath_forallfiles")); @@ -7218,8 +7222,9 @@ private void changeFileDestination(TorrentOpenFileOptions[] infos, boolean allAt } } - if (sFilterPath != null){ - fDialog.setFilterPath(sFilterPath); + if ( sFilterPath != null ){ + + Utils.setFilterPathWithTimeout( fDialog, sFilterPath ); } fDialog.setFileName(sFileName);