Author: mhutch
Date: 2008-02-07 20:03:38 -0500 (Thu, 07 Feb 2008)
New Revision: 95213
Modified:
branches/monodevelop/main/1.0/src/addins/CBinding/ChangeLog
branches/monodevelop/main/1.0/src/addins/CBinding/Parser/TagDatabaseManager.cs
branches/monodevelop/main/1.0/src/core/MonoDevelop.Core/ChangeLog
branches/monodevelop/main/1.0/src/core/MonoDevelop.Core/MonoDevelop.Core.Execution/ProcessWrapper.cs
Log:
In src/addins/CBinding:
2008-02-07 Michael Hutchinson <[EMAIL PROTECTED]>
* Parser/TagDatabaseManager.cs: Improve error handling. Should fix "Bug
359567 - MonoDevelop crashes when creating/opening C++ Console
Project".
In src/core/MonoDevelop.Core:
2008-02-07 Michael Hutchinson <[EMAIL PROTECTED]>
* MonoDevelop.Core.Execution/ProcessWrapper.cs: Add a WaitForOutput
overload
with a time limit.
Modified: branches/monodevelop/main/1.0/src/addins/CBinding/ChangeLog
===================================================================
--- branches/monodevelop/main/1.0/src/addins/CBinding/ChangeLog 2008-02-08
00:59:07 UTC (rev 95212)
+++ branches/monodevelop/main/1.0/src/addins/CBinding/ChangeLog 2008-02-08
01:03:38 UTC (rev 95213)
@@ -1,3 +1,8 @@
+2008-02-07 Michael Hutchinson <[EMAIL PROTECTED]>
+
+ * Parser/TagDatabaseManager.cs: Improve error handling. Should fix "Bug
+ 359567 - MonoDevelop crashes when creating/opening C++ Console
Project".
+
2008-01-25 Lluis Sanchez Gual <[EMAIL PROTECTED]>
* CBinding.addin.xml: Update MD version.
Modified:
branches/monodevelop/main/1.0/src/addins/CBinding/Parser/TagDatabaseManager.cs
===================================================================
---
branches/monodevelop/main/1.0/src/addins/CBinding/Parser/TagDatabaseManager.cs
2008-02-08 00:59:07 UTC (rev 95212)
+++
branches/monodevelop/main/1.0/src/addins/CBinding/Parser/TagDatabaseManager.cs
2008-02-08 01:03:38 UTC (rev 95213)
@@ -72,7 +72,7 @@
}
}
- bool AreDepsInstalled {
+ bool DepsInstalled {
get {
if (!checkedCtagsInstalled) {
checkedCtagsInstalled = true;
@@ -88,10 +88,19 @@
LoggingService.LogWarning
("Cannot update C/C++ tags database because gcc is not installed.");
return false;
}
- ctagsInstalled = true;
+ lock (parsingJobs) {
+ ctagsInstalled = true;
+ }
}
return ctagsInstalled;
}
+ set {
+ //don't assume that the caller is correct :-)
+ if (value)
+ checkedCtagsInstalled = false; //wil
re-determine ctagsInstalled on next getting
+ else
+ ctagsInstalled = false;
+ }
}
private string[] Headers (string filename, bool with_system)
@@ -167,29 +176,38 @@
private void FillFileInformation (FileInformation fileInfo)
{
- if (!AreDepsInstalled)
+ if (!DepsInstalled)
return;
string confdir = PropertyService.ConfigPath;
string tagFileName = Path.GetFileName
(fileInfo.FileName) + ".tag";
string tagdir = Path.Combine (confdir, "system-tags");
string tagFullFileName = Path.Combine (tagdir,
tagFileName);
- string ctags_options = "--C++-kinds=+p+u
--fields=+a-f+S --language-force=C++ --excmd=pattern -f " + tagFullFileName + "
" + fileInfo.FileName;
+ string ctags_options = "--C++-kinds=+p+u
--fields=+a-f+S --language-force=C++ --excmd=pattern -f '" + tagFullFileName +
"' " + fileInfo.FileName;
if (!Directory.Exists (tagdir))
Directory.CreateDirectory (tagdir);
- if (!File.Exists (tagFullFileName)) {
- ProcessWrapper p;
-
+ if (!File.Exists (tagFullFileName) ||
File.GetLastWriteTimeUtc (tagFullFileName) < File.GetLastWriteTimeUtc
(fileInfo.FileName)) {
+ ProcessWrapper p = null;
+ System.IO.StringWriter output = null;
try {
- p = Runtime.ProcessService.StartProcess
("ctags", ctags_options, null, null);
- p.WaitForExit ();
+ output = new System.IO.StringWriter ();
+
+ p = Runtime.ProcessService.StartProcess
("ctags", ctags_options, null, output, output, null);
+ p.WaitForOutput (10000);
+ if (p.ExitCode != 0 || !File.Exists
(tagFullFileName)) {
+ LoggingService.LogError ("Ctags
did not successfully populate the tags database '{0}' from '{1}' within ten
seconds.\nOutput: {2}", tagFullFileName, output.ToString ());
+ return;
+ }
} catch (Exception ex) {
throw new IOException ("Could not
create tags database (You must have exuberant ctags installed).", ex);
+ } finally {
+ if (output != null)
+ output.Dispose ();
+ if (p != null)
+ p.Dispose ();
}
-
- p.Close ();
}
string ctags_output;
@@ -215,21 +233,26 @@
private void ParsingThread ()
{
- while (parsingJobs.Count > 0)
- {
- ProjectFilePair p;
+ try {
+ while (parsingJobs.Count > 0) {
+ ProjectFilePair p;
- lock (parsingJobs) {
- p = parsingJobs.Dequeue ();
+ lock (parsingJobs) {
+ p = parsingJobs.Dequeue ();
+ }
+
+ DoUpdateFileTags (p.Project, p.File);
}
-
- DoUpdateFileTags (p.Project, p.File);
+ } catch (Exception ex) {
+ LoggingService.LogError ("Unhandled error
updating parser database. Disabling C/C++ parsing.", ex);
+ DepsInstalled = false;
+ return;
}
}
public void UpdateFileTags (Project project, string filename)
{
- if (!AreDepsInstalled)
+ if (!DepsInstalled)
return;
ProjectFilePair p = new ProjectFilePair (project,
filename);
@@ -248,7 +271,7 @@
private void DoUpdateFileTags (Project project, string filename)
{
- if (!AreDepsInstalled)
+ if (!DepsInstalled)
return;
string[] headers = Headers (filename, false);
@@ -256,17 +279,29 @@
string[] system_headers = diff (Headers (filename,
true), headers);
- ProcessWrapper p;
-
+ ProcessWrapper p = null;
+ System.IO.StringWriter output = null, error = null;
+ string ctags_output = string.Empty;
try {
- p = Runtime.ProcessService.StartProcess
("ctags", ctags_options, null, null);
- p.WaitForExit (10000); //If no return detected
in 10s, kill anyway
+ output = new System.IO.StringWriter ();
+ error = new System.IO.StringWriter ();
+ p = Runtime.ProcessService.StartProcess
("ctags", ctags_options, null, output, error, null);
+ p.WaitForOutput (10000);
+ if (p.ExitCode != 0) {
+ LoggingService.LogError ("Ctags did not
successfully populate the tags database from '{0}' within ten seconds.\nError
output: {1}", filename, error.ToString ());
+ return;
+ }
+ ctags_output = output.ToString ();
} catch (Exception ex) {
throw new IOException ("Could not create tags
database (You must have exuberant ctags installed).", ex);
+ } finally {
+ if (output != null)
+ output.Dispose ();
+ if (error != null)
+ error.Dispose ();
+ if (p != null)
+ p.Dispose ();
}
-
- string ctags_output = p.StandardOutput.ReadToEnd ();
- p.Close ();
ProjectInformation info =
ProjectInformationManager.Instance.Get (project);
string tagEntry;
Modified: branches/monodevelop/main/1.0/src/core/MonoDevelop.Core/ChangeLog
===================================================================
--- branches/monodevelop/main/1.0/src/core/MonoDevelop.Core/ChangeLog
2008-02-08 00:59:07 UTC (rev 95212)
+++ branches/monodevelop/main/1.0/src/core/MonoDevelop.Core/ChangeLog
2008-02-08 01:03:38 UTC (rev 95213)
@@ -1,3 +1,8 @@
+2008-02-07 Michael Hutchinson <[EMAIL PROTECTED]>
+
+ * MonoDevelop.Core.Execution/ProcessWrapper.cs: Add a WaitForOutput
overload
+ with a time limit.
+
2008-02-04 Michael Hutchinson <[EMAIL PROTECTED]>
* MonoDevelop.Core/Runtime.cs: Use MD's config directory for addin
engine
Modified:
branches/monodevelop/main/1.0/src/core/MonoDevelop.Core/MonoDevelop.Core.Execution/ProcessWrapper.cs
===================================================================
---
branches/monodevelop/main/1.0/src/core/MonoDevelop.Core/MonoDevelop.Core.Execution/ProcessWrapper.cs
2008-02-08 00:59:07 UTC (rev 95212)
+++
branches/monodevelop/main/1.0/src/core/MonoDevelop.Core/MonoDevelop.Core.Execution/ProcessWrapper.cs
2008-02-08 01:03:38 UTC (rev 95213)
@@ -33,15 +33,20 @@
captureErrorThread.Start ();
}
- public void WaitForOutput ()
+ public void WaitForOutput (int milliseconds)
{
- WaitForExit ();
+ WaitForExit (milliseconds);
lock (this) {
done = true;
}
WaitHandle.WaitAll (new WaitHandle[] {endEventOut,
endEventErr});
}
+ public void WaitForOutput ()
+ {
+ WaitForOutput (-1);
+ }
+
private void CaptureOutput ()
{
try {
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches