Skip to content

Commit

Permalink
Bugfix for global Book Parameters to be accessible even without any book
Browse files Browse the repository at this point in the history
  • Loading branch information
hbitteur committed Dec 2, 2021
1 parent d71e9d7 commit 9910a09
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
9 changes: 6 additions & 3 deletions src/main/org/audiveris/omr/score/ui/BookParameters.java
Expand Up @@ -246,7 +246,7 @@ public BookParameters (SheetStub stub)
/**
* Commit the user actions.
*
* @param book the related book
* @param book the related book if any, perhaps null
* @return true if committed, false otherwise
*/
public boolean commit (Book book)
Expand Down Expand Up @@ -276,8 +276,11 @@ public boolean commit (Book book)
if (tab == 0) {
defaultModified = true;
} else {
book.setModified(true);
bookModified = true;
// Test on book not really needed (unless tabs order gets changed one day)
if (book != null) {
book.setModified(true);
bookModified = true;
}
}
}
}
Expand Down
26 changes: 17 additions & 9 deletions src/main/org/audiveris/omr/sheet/ui/BookActions.java
Expand Up @@ -679,15 +679,17 @@ public Task<Void, Void> exportSheetAs (ActionEvent e)
*/
public static void applyUserSettings (final SheetStub stub)
{
final Book book = stub.getBook();
final Book book = (stub != null) ? stub.getBook() : null;

// Dialog already active?
final JDialog activeDialog = book.getParameterDialog();
if (book != null) {
// Dialog already active?
final JDialog activeDialog = book.getParameterDialog();

if (activeDialog != null) {
activeDialog.setVisible(true);
if (activeDialog != null) {
activeDialog.setVisible(true);

return;
return;
}
}

// Create a brand new dialog
Expand All @@ -705,12 +707,16 @@ public static void applyUserSettings (final SheetStub stub)
@Override
public void windowClosing (WindowEvent we)
{
book.setParameterDialog(null);
if (book != null) {
book.setParameterDialog(null);
}
dialog.dispose();
}
});

book.setParameterDialog(dialog);
if (book != null) {
book.setParameterDialog(dialog);
}

// User actions on buttons OK, Apply, Cancel
final JOptionPane optionPane = new JOptionPane(
Expand Down Expand Up @@ -738,7 +744,9 @@ public void windowClosing (WindowEvent we)
}

if (exit) {
book.setParameterDialog(null);
if (book != null) {
book.setParameterDialog(null);
}
dialog.setVisible(false);
dialog.dispose();
} else {
Expand Down

0 comments on commit 9910a09

Please sign in to comment.