Author: timotei
Date: Sun May 1 22:14:20 2011
New Revision: 49340
URL: http://svn.gna.org/viewcvs/wesnoth?rev=49340&view=rev
Log:
eclipse plugin:Fix for bug #18080.
Prevent a NullReferenceException when
there are errors running the custom tool
Modified:
trunk/utils/java/org.wesnoth/src/org/wesnoth/Messages.java
trunk/utils/java/org.wesnoth/src/org/wesnoth/messages.properties
trunk/utils/java/org.wesnoth/src/org/wesnoth/preprocessor/Define.java
trunk/utils/java/org.wesnoth/src/org/wesnoth/utils/WMLTools.java
Modified: trunk/utils/java/org.wesnoth/src/org/wesnoth/Messages.java
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/java/org.wesnoth/src/org/wesnoth/Messages.java?rev=49340&r1=49339&r2=49340&view=diff
==============================================================================
--- trunk/utils/java/org.wesnoth/src/org/wesnoth/Messages.java (original)
+++ trunk/utils/java/org.wesnoth/src/org/wesnoth/Messages.java Sun May 1
22:14:20 2011
@@ -77,6 +77,7 @@
public static String CampaignPage2_8;
public static String Define_0;
public static String Define_1;
+ public static String Define_2;
public static String EmptyProjectNewWizard_0;
public static String EmptyProjectNewWizard_1;
public static String EmptyProjectPage0_1;
Modified: trunk/utils/java/org.wesnoth/src/org/wesnoth/messages.properties
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/java/org.wesnoth/src/org/wesnoth/messages.properties?rev=49340&r1=49339&r2=49340&view=diff
==============================================================================
--- trunk/utils/java/org.wesnoth/src/org/wesnoth/messages.properties (original)
+++ trunk/utils/java/org.wesnoth/src/org/wesnoth/messages.properties Sun May 1
22:14:20 2011
@@ -61,7 +61,8 @@
CampaignPage2_7=Define* :
CampaignPage2_8=Difficulties:
Define_0=loaded
-Define_1=\ defines for file:
+Define_1=\ defines for file:
+Define_2=There was an error on creating the Defines SAX handler
EmptyProjectNewWizard_0=Create a new empty project
EmptyProjectNewWizard_1=Creating the project structure...
EmptyProjectPage0_1=Empty project wizard
Modified: trunk/utils/java/org.wesnoth/src/org/wesnoth/preprocessor/Define.java
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/java/org.wesnoth/src/org/wesnoth/preprocessor/Define.java?rev=49340&r1=49339&r2=49340&view=diff
==============================================================================
--- trunk/utils/java/org.wesnoth/src/org/wesnoth/preprocessor/Define.java
(original)
+++ trunk/utils/java/org.wesnoth/src/org/wesnoth/preprocessor/Define.java Sun
May 1 22:14:20 2011
@@ -9,6 +9,7 @@
package org.wesnoth.preprocessor;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -84,15 +85,20 @@
/**
* Reads the defines from the specified file
* @param file
- * @return
+ * @return Returns a map of defines
*/
public static Map<String, Define> readDefines(String file)
{
DefinesSAXHandler handler = (DefinesSAXHandler) ResourceUtils.
getWMLSAXHandlerFromResource(file, new
DefinesSAXHandler());
- Logger.getInstance().log(Messages.Define_0 +
handler.getDefines().size() + Messages.Define_1 + file);
- return handler.getDefines();
+ if (handler != null){
+ Logger.getInstance().log(Messages.Define_0 +
handler.getDefines().size() + Messages.Define_1 + file);
+ return handler.getDefines();
+ }
+
+ Logger.getInstance().log(Messages.Define_2);
+ return new HashMap<String, Define>(0);
}
/**
Modified: trunk/utils/java/org.wesnoth/src/org/wesnoth/utils/WMLTools.java
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/java/org.wesnoth/src/org/wesnoth/utils/WMLTools.java?rev=49340&r1=49339&r2=49340&view=diff
==============================================================================
--- trunk/utils/java/org.wesnoth/src/org/wesnoth/utils/WMLTools.java (original)
+++ trunk/utils/java/org.wesnoth/src/org/wesnoth/utils/WMLTools.java Sun May 1
22:14:20 2011
@@ -42,6 +42,7 @@
* @param dryrun true to run "wmlindent" in dry mode - i.e. no changes
in the config file.
* @param stdout The array of streams where to output the stdout content
* @param stderr The array of streams where to output the stderr content
+ * @return null if there were errors or an ExternalToolInvoker instance
*/
public static ExternalToolInvoker runWMLIndent(String resourcePath,
String stdin,
boolean dryrun, OutputStream[] stdout, OutputStream[]
stderr)
@@ -75,7 +76,7 @@
/**
* Runs a wmlparser on the target resource
* @param resourcePath
- * @return
+ * @return null if there were errors or an ExternalToolInvoker instance
*/
public static ExternalToolInvoker runWMLParser2(String resourcePath)
{
@@ -119,6 +120,7 @@
*
* @param resourcePath the full path of the target where "wmllint" will
be runned on
* @param dryrun true to run "wmllint" in dry mode - i.e. no changes in
the config file.
+ * @return null if there were errors or an ExternalToolInvoker instance
*/
public static ExternalToolInvoker runWMLLint(String resourcePath,
boolean dryrun, boolean showProgress)
{
@@ -171,7 +173,7 @@
* Runs "wmlscope" on the specified resource (directory/file)
*
* @param resourcePath the full path of the target where "wmlindent"
will be runned on
- * @return
+ * @return null if there were errors or an ExternalToolInvoker instance
*/
public static ExternalToolInvoker runWMLScope(String resourcePath,
boolean showProgress)
{
@@ -184,7 +186,7 @@
* @param resourcePath the full path of the target where "wmlindent"
will be runned on
* @param stdout The array of streams where to output the stdout content
* @param stderr The array of streams where to output the stderr content
- * @return
+ * @return null if there were errors or an ExternalToolInvoker instance
*/
public static ExternalToolInvoker runWMLScope(String resourcePath,
boolean showProgress,
OutputStream[] stdout, OutputStream[] stderr)
@@ -382,7 +384,7 @@
* @param containerPath The container to upload
* @param stdout The array of streams where to output the stdout content
* @param stderr The array of streams where to output the stderr content
- * @return
+ * @return null if there were errors or an ExternalToolInvoker instance
*/
public static ExternalToolInvoker runWesnothAddonManager(String
containerPath,
OutputStream[] stdout, OutputStream[] stderr)
@@ -448,16 +450,23 @@
*
* @param filePath the file to be processed by the wml tool
* @param wmlTool the wml tool file
- * @return
+ * @return True if the prerequisites are valid or false otherwise
*/
public static boolean checkPrerequisites(String filePath, String
wmlTool)
{
+ if (filePath == null || filePath.isEmpty() || !new
File(filePath).exists())
+ {
+ Logger.getInstance().logWarn(Messages.WMLTools_48 + filePath);
+ return false;
+ }
+
if (Preferences.getString(Constants.P_PYTHON_PATH).equals(""))
//$NON-NLS-1$
{
GUIUtils.showWarnMessageBox(Messages.WMLTools_42 +
Messages.WMLTools_43);
return false;
}
+
if (wmlTool != null)
{
if
(Preferences.getString(Constants.P_WESNOTH_WMLTOOLS_DIR).equals(""))
//$NON-NLS-1$
@@ -475,11 +484,6 @@
wmlToolFile));
return false;
}
- }
- if (filePath != null && (filePath.isEmpty() || !new
File(filePath).exists()))
- {
- Logger.getInstance().logWarn(Messages.WMLTools_48 +
filePath);
- return false;
}
return true;
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits