Browse Source

Fixed AvalonEdit bug when deleting text including a folded section.

Fixed DBNull issue in UsageDataUploader.FetchDataForUpload.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4923 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 17 years ago
parent
commit
465a5f38e9
  1. 4
      src/AddIns/Misc/UsageDataCollector/UsageDataSessionWriter.cs
  2. 6
      src/AddIns/Misc/UsageDataCollector/UsageDataUploader.cs
  3. 36
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingManager.cs
  4. 14
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingSection.cs

4
src/AddIns/Misc/UsageDataCollector/UsageDataSessionWriter.cs

@ -159,6 +159,8 @@ namespace ICSharpCode.UsageDataCollector @@ -159,6 +159,8 @@ namespace ICSharpCode.UsageDataCollector
/// <returns>ID that can be used for <see cref="WriteEndTimeForFeature"/></returns>
public long AddFeatureUse(string featureName, string activationMethod)
{
if (featureName == null)
throw new ArgumentNullException("featureName");
long featureRowId;
using (SQLiteTransaction transaction = this.connection.BeginTransaction()) {
using (SQLiteCommand cmd = this.connection.CreateCommand()) {
@ -196,6 +198,8 @@ namespace ICSharpCode.UsageDataCollector @@ -196,6 +198,8 @@ namespace ICSharpCode.UsageDataCollector
/// <param name="stacktrace">Stacktrace</param>
public void AddException(string exceptionType, string stacktrace)
{
if (exceptionType == null)
throw new ArgumentNullException("exceptionType");
using (SQLiteCommand cmd = this.connection.CreateCommand()) {
cmd.CommandText = "INSERT INTO Exceptions (session, time, type, stackTrace)" +
" VALUES (?, datetime('now'), ?, ?);";

6
src/AddIns/Misc/UsageDataCollector/UsageDataUploader.cs

@ -185,7 +185,8 @@ namespace ICSharpCode.UsageDataCollector @@ -185,7 +185,8 @@ namespace ICSharpCode.UsageDataCollector
if (!reader.IsDBNull(2))
featureUse.EndTime = reader.GetDateTime(2);
featureUse.FeatureName = stringInterning.Intern(reader.GetString(3));
featureUse.ActivationMethod = stringInterning.Intern(reader.GetString(4));
if (!reader.IsDBNull(4))
featureUse.ActivationMethod = stringInterning.Intern(reader.GetString(4));
session.FeatureUses.Add(featureUse);
}
}
@ -201,7 +202,8 @@ namespace ICSharpCode.UsageDataCollector @@ -201,7 +202,8 @@ namespace ICSharpCode.UsageDataCollector
UsageDataException exception = new UsageDataException();
exception.Time = reader.GetDateTime(1);
exception.ExceptionType = stringInterning.Intern(reader.GetString(2));
exception.StackTrace = stringInterning.Intern(reader.GetString(3));
if (!reader.IsDBNull(3))
exception.StackTrace = stringInterning.Intern(reader.GetString(3));
session.Exceptions.Add(exception);
}
}

36
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingManager.cs

@ -22,7 +22,7 @@ namespace ICSharpCode.AvalonEdit.Folding @@ -22,7 +22,7 @@ namespace ICSharpCode.AvalonEdit.Folding
/// <summary>
/// Stores a list of foldings for a specific TextView and TextDocument.
/// </summary>
public class FoldingManager
public class FoldingManager : IWeakEventListener
{
internal readonly TextView textView;
internal readonly TextDocument document;
@ -41,7 +41,39 @@ namespace ICSharpCode.AvalonEdit.Folding @@ -41,7 +41,39 @@ namespace ICSharpCode.AvalonEdit.Folding
throw new ArgumentNullException("document");
this.textView = textView;
this.document = document;
this.foldings = new TextSegmentCollection<FoldingSection>(document);
this.foldings = new TextSegmentCollection<FoldingSection>();
document.VerifyAccess();
TextDocumentWeakEventManager.Changed.AddListener(document, this);
}
#endregion
#region ReceiveWeakEvent
/// <inheritdoc/>
protected virtual bool ReceiveWeakEvent(Type managerType, object sender, EventArgs e)
{
if (managerType == typeof(TextDocumentWeakEventManager.Changed)) {
OnDocumentChanged((DocumentChangeEventArgs)e);
return true;
}
return false;
}
bool IWeakEventListener.ReceiveWeakEvent(Type managerType, object sender, EventArgs e)
{
return ReceiveWeakEvent(managerType, sender, e);
}
void OnDocumentChanged(DocumentChangeEventArgs e)
{
foldings.UpdateOffsets(e);
FoldingSection s = foldings.FindFirstSegmentWithStartAfter(e.Offset);
while (s != null && s.StartOffset == e.Offset) {
FoldingSection next = foldings.GetNextSegment(s);
if (s.Length == 0) {
RemoveFolding(s);
}
s = next;
}
}
#endregion

14
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingSection.cs

@ -40,10 +40,7 @@ namespace ICSharpCode.AvalonEdit.Folding @@ -40,10 +40,7 @@ namespace ICSharpCode.AvalonEdit.Folding
}
}
} else {
if (collapsedSection != null) {
collapsedSection.Uncollapse();
collapsedSection = null;
}
RemoveCollapsedLineSection();
}
if (manager != null)
manager.textView.Redraw(this, DispatcherPriority.Normal);
@ -74,12 +71,17 @@ namespace ICSharpCode.AvalonEdit.Folding @@ -74,12 +71,17 @@ namespace ICSharpCode.AvalonEdit.Folding
this.Length = endOffset - startOffset;
}
internal void Removed()
void RemoveCollapsedLineSection()
{
if (collapsedSection != null) {
collapsedSection.Uncollapse();
if (collapsedSection.Start != null)
collapsedSection.Uncollapse();
collapsedSection = null;
}
}
internal void Removed()
{
manager = null;
}
}

Loading…
Cancel
Save