Non-zero check for number of columns in diff view.

Setting zero as number of columns in the diff view causes web browser to freeze
(tested on Firefox). The zero value is persisted in account_diff_preferences
and the issue with the freezing web browser is persistent until an admin
changes the value in the database.

This change adds a validity check for the "Columns" field and report an error
in case when it is zero.

Change-Id: I16e5be7b8781d125f5647b1303660145b8101fce
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
This commit is contained in:
Sasa Zivkov
2011-02-01 12:46:35 +01:00
parent 84739ac801
commit 0e8c04781d
3 changed files with 8 additions and 0 deletions

View File

@@ -32,6 +32,7 @@ public interface PatchConstants extends Constants {
String patchHistoryTitle();
String disabledOnLargeFiles();
String intralineFailure();
String illegalNumberOfColumns();
String upToChange();
String linePrev();

View File

@@ -14,6 +14,7 @@ patchHeaderNew = New Version
patchHistoryTitle = Patch History
disabledOnLargeFiles = Disabled on very large source files.
intralineFailure = Intraline difference not available due to server error.
illegalNumberOfColumns = The number of columns cannot be zero or negative
upToChange = Up to change
linePrev = Previous line

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.client.patches;
import com.google.gerrit.client.ErrorDialog;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.account.Util;
import com.google.gerrit.client.rpc.GerritCallback;
@@ -216,6 +217,11 @@ public class PatchScriptSettingsPanel extends Composite implements
}
private void update() {
if (colWidth.getIntValue() <= 0) {
new ErrorDialog(PatchUtil.C.illegalNumberOfColumns()).center();
return;
}
AccountDiffPreference dp = new AccountDiffPreference(getValue());
dp.setIgnoreWhitespace(getIgnoreWhitespace());
dp.setContext(getContext());