Skip to content

Commit

Permalink
Try to ensure filter path path is responding when setting on dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
parg committed Nov 25, 2024
1 parent e4a5c8d commit 3942260
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
33 changes: 33 additions & 0 deletions uis/src/com/biglybt/ui/swt/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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"));

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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"));
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 3942260

Please sign in to comment.