Finally separate the EquationEditor formula cache from the presentation cache.
diff --git a/PowerPointLaTeX/PowerPointLaTeX/Cache/LocalCache.cs b/PowerPointLaTeX/PowerPointLaTeX/Cache/LocalCache.cs
index bd50e2d..1c62a44 100644
--- a/PowerPointLaTeX/PowerPointLaTeX/Cache/LocalCache.cs
+++ b/PowerPointLaTeX/PowerPointLaTeX/Cache/LocalCache.cs
@@ -7,7 +7,22 @@
{
class LocalCache : ICacheStorage
{
- Dictionary<string, CacheEntry> cache = new Dictionary<string, CacheEntry>();
+ private Dictionary<string, CacheEntry> cache = new Dictionary<string, CacheEntry>();
+ private ICacheStorage masterStorage;
+
+ public ICacheStorage MasterStorage
+ {
+ get { return masterStorage; }
+ }
+
+ public LocalCache() {
+ this.masterStorage = null;
+ }
+
+ public LocalCache(ICacheStorage masterStorage)
+ {
+ this.masterStorage = masterStorage;
+ }
#region ICacheStorage Members
@@ -22,7 +37,12 @@
if( cache.TryGetValue(code, out entry) ) {
return entry;
}
- else {
+ else if (masterStorage != null)
+ {
+ return masterStorage.Get(code);
+ }
+ else
+ {
return null;
}
}
diff --git a/PowerPointLaTeX/PowerPointLaTeX/Equations/EquationEditor.Designer.cs b/PowerPointLaTeX/PowerPointLaTeX/Equations/EquationEditor.Designer.cs
index 0986ebf..4493a38 100644
--- a/PowerPointLaTeX/PowerPointLaTeX/Equations/EquationEditor.Designer.cs
+++ b/PowerPointLaTeX/PowerPointLaTeX/Equations/EquationEditor.Designer.cs
@@ -39,9 +39,9 @@
this.tableLayoutPanel1.SuspendLayout();
this.flowLayoutPanel1.SuspendLayout();
this.tableLayoutPanel2.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize) (this.formulaPreview)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.formulaPreview)).BeginInit();
this.panel1.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize) (this.fontSizeUpDown)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.fontSizeUpDown)).BeginInit();
this.SuspendLayout();
//
// applyButton
@@ -49,21 +49,22 @@
applyButton.AutoSize = true;
applyButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
applyButton.DialogResult = System.Windows.Forms.DialogResult.OK;
- applyButton.Location = new System.Drawing.Point( 82, 3 );
+ applyButton.Location = new System.Drawing.Point(82, 3);
applyButton.Name = "applyButton";
- applyButton.Size = new System.Drawing.Size( 88, 23 );
+ applyButton.Size = new System.Drawing.Size(88, 23);
applyButton.TabIndex = 0;
applyButton.Text = "Apply Changes";
applyButton.UseVisualStyleBackColor = true;
+ applyButton.Click += new System.EventHandler(this.applyButton_Click);
//
// cancelButton
//
cancelButton.AutoSize = true;
cancelButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
- cancelButton.Location = new System.Drawing.Point( 176, 3 );
+ cancelButton.Location = new System.Drawing.Point(176, 3);
cancelButton.Name = "cancelButton";
- cancelButton.Size = new System.Drawing.Size( 50, 23 );
+ cancelButton.Size = new System.Drawing.Size(50, 23);
cancelButton.TabIndex = 1;
cancelButton.Text = "Cancel";
cancelButton.UseVisualStyleBackColor = true;
@@ -71,9 +72,9 @@
// label1
//
label1.AutoSize = true;
- label1.Location = new System.Drawing.Point( 3, 8 );
+ label1.Location = new System.Drawing.Point(3, 8);
label1.Name = "label1";
- label1.Size = new System.Drawing.Size( 54, 13 );
+ label1.Size = new System.Drawing.Size(54, 13);
label1.TabIndex = 6;
label1.Text = "Font Size:";
//
@@ -81,49 +82,49 @@
//
this.tableLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.tableLayoutPanel1.ColumnCount = 2;
- this.tableLayoutPanel1.ColumnStyles.Add( new System.Windows.Forms.ColumnStyle( System.Windows.Forms.SizeType.Percent, 100F ) );
- this.tableLayoutPanel1.ColumnStyles.Add( new System.Windows.Forms.ColumnStyle( System.Windows.Forms.SizeType.Absolute, 235F ) );
- this.tableLayoutPanel1.Controls.Add( this.flowLayoutPanel1, 1, 2 );
- this.tableLayoutPanel1.Controls.Add( this.formulaText, 0, 1 );
- this.tableLayoutPanel1.Controls.Add( this.tableLayoutPanel2, 0, 0 );
- this.tableLayoutPanel1.Controls.Add( this.panel1, 0, 2 );
+ this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
+ this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 235F));
+ this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel1, 1, 2);
+ this.tableLayoutPanel1.Controls.Add(this.formulaText, 0, 1);
+ this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel2, 0, 0);
+ this.tableLayoutPanel1.Controls.Add(this.panel1, 0, 2);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
- this.tableLayoutPanel1.Location = new System.Drawing.Point( 0, 0 );
+ this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 3;
- this.tableLayoutPanel1.RowStyles.Add( new System.Windows.Forms.RowStyle( System.Windows.Forms.SizeType.Percent, 100F ) );
- this.tableLayoutPanel1.RowStyles.Add( new System.Windows.Forms.RowStyle( System.Windows.Forms.SizeType.Absolute, 102F ) );
- this.tableLayoutPanel1.RowStyles.Add( new System.Windows.Forms.RowStyle() );
- this.tableLayoutPanel1.RowStyles.Add( new System.Windows.Forms.RowStyle( System.Windows.Forms.SizeType.Absolute, 8F ) );
- this.tableLayoutPanel1.Size = new System.Drawing.Size( 459, 250 );
+ this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
+ this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 102F));
+ this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
+ this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 8F));
+ this.tableLayoutPanel1.Size = new System.Drawing.Size(459, 250);
this.tableLayoutPanel1.TabIndex = 0;
//
// flowLayoutPanel1
//
this.flowLayoutPanel1.AutoSize = true;
this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
- this.flowLayoutPanel1.Controls.Add( cancelButton );
- this.flowLayoutPanel1.Controls.Add( applyButton );
+ this.flowLayoutPanel1.Controls.Add(cancelButton);
+ this.flowLayoutPanel1.Controls.Add(applyButton);
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft;
- this.flowLayoutPanel1.Location = new System.Drawing.Point( 227, 218 );
+ this.flowLayoutPanel1.Location = new System.Drawing.Point(227, 218);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
- this.flowLayoutPanel1.Size = new System.Drawing.Size( 229, 29 );
+ this.flowLayoutPanel1.Size = new System.Drawing.Size(229, 29);
this.flowLayoutPanel1.TabIndex = 1;
//
// formulaText
//
this.formulaText.AcceptsReturn = true;
this.formulaText.AcceptsTab = true;
- this.tableLayoutPanel1.SetColumnSpan( this.formulaText, 2 );
+ this.tableLayoutPanel1.SetColumnSpan(this.formulaText, 2);
this.formulaText.Dock = System.Windows.Forms.DockStyle.Fill;
- this.formulaText.Location = new System.Drawing.Point( 3, 116 );
+ this.formulaText.Location = new System.Drawing.Point(3, 116);
this.formulaText.Multiline = true;
this.formulaText.Name = "formulaText";
- this.formulaText.Size = new System.Drawing.Size( 453, 96 );
+ this.formulaText.Size = new System.Drawing.Size(453, 96);
this.formulaText.TabIndex = 2;
this.formulaText.UseSystemPasswordChar = true;
- this.formulaText.TextChanged += new System.EventHandler( this.formulaText_TextChanged );
+ this.formulaText.TextChanged += new System.EventHandler(this.formulaText_TextChanged);
//
// tableLayoutPanel2
//
@@ -131,26 +132,26 @@
this.tableLayoutPanel2.AutoSize = true;
this.tableLayoutPanel2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.tableLayoutPanel2.ColumnCount = 1;
- this.tableLayoutPanel1.SetColumnSpan( this.tableLayoutPanel2, 2 );
- this.tableLayoutPanel2.ColumnStyles.Add( new System.Windows.Forms.ColumnStyle() );
- this.tableLayoutPanel2.ColumnStyles.Add( new System.Windows.Forms.ColumnStyle( System.Windows.Forms.SizeType.Absolute, 20F ) );
- this.tableLayoutPanel2.Controls.Add( this.formulaPreview, 0, 0 );
+ this.tableLayoutPanel1.SetColumnSpan(this.tableLayoutPanel2, 2);
+ this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
+ this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel2.Controls.Add(this.formulaPreview, 0, 0);
this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel2.GrowStyle = System.Windows.Forms.TableLayoutPanelGrowStyle.AddColumns;
- this.tableLayoutPanel2.Location = new System.Drawing.Point( 3, 3 );
+ this.tableLayoutPanel2.Location = new System.Drawing.Point(3, 3);
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
this.tableLayoutPanel2.RowCount = 1;
- this.tableLayoutPanel2.RowStyles.Add( new System.Windows.Forms.RowStyle() );
- this.tableLayoutPanel2.Size = new System.Drawing.Size( 453, 107 );
+ this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
+ this.tableLayoutPanel2.Size = new System.Drawing.Size(453, 107);
this.tableLayoutPanel2.TabIndex = 3;
//
// formulaPreview
//
this.formulaPreview.Anchor = System.Windows.Forms.AnchorStyles.None;
this.formulaPreview.Cursor = System.Windows.Forms.Cursors.Arrow;
- this.formulaPreview.Location = new System.Drawing.Point( 221, 48 );
+ this.formulaPreview.Location = new System.Drawing.Point(221, 48);
this.formulaPreview.Name = "formulaPreview";
- this.formulaPreview.Size = new System.Drawing.Size( 10, 10 );
+ this.formulaPreview.Size = new System.Drawing.Size(10, 10);
this.formulaPreview.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.formulaPreview.TabIndex = 6;
this.formulaPreview.TabStop = false;
@@ -158,54 +159,54 @@
// panel1
//
this.panel1.AutoSize = true;
- this.panel1.Controls.Add( this.fontSizeUpDown );
- this.panel1.Controls.Add( label1 );
+ this.panel1.Controls.Add(this.fontSizeUpDown);
+ this.panel1.Controls.Add(label1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
- this.panel1.Location = new System.Drawing.Point( 3, 218 );
+ this.panel1.Location = new System.Drawing.Point(3, 218);
this.panel1.Name = "panel1";
- this.panel1.Size = new System.Drawing.Size( 218, 29 );
+ this.panel1.Size = new System.Drawing.Size(218, 29);
this.panel1.TabIndex = 4;
//
// fontSizeUpDown
//
- this.fontSizeUpDown.Location = new System.Drawing.Point( 63, 6 );
- this.fontSizeUpDown.Minimum = new decimal( new int[] {
+ this.fontSizeUpDown.Location = new System.Drawing.Point(63, 6);
+ this.fontSizeUpDown.Minimum = new decimal(new int[] {
1,
0,
0,
- 0} );
+ 0});
this.fontSizeUpDown.Name = "fontSizeUpDown";
- this.fontSizeUpDown.Size = new System.Drawing.Size( 42, 20 );
+ this.fontSizeUpDown.Size = new System.Drawing.Size(42, 20);
this.fontSizeUpDown.TabIndex = 7;
- this.fontSizeUpDown.Value = new decimal( new int[] {
+ this.fontSizeUpDown.Value = new decimal(new int[] {
1,
0,
0,
- 0} );
- this.fontSizeUpDown.ValueChanged += new System.EventHandler( this.fontSizeUpDown_ValueChanged );
- this.fontSizeUpDown.Click += new System.EventHandler( this.fontSizeUpDown_Click );
+ 0});
+ this.fontSizeUpDown.ValueChanged += new System.EventHandler(this.fontSizeUpDown_ValueChanged);
+ this.fontSizeUpDown.Click += new System.EventHandler(this.fontSizeUpDown_Click);
//
// EquationEditor
//
this.AcceptButton = applyButton;
- this.AutoScaleDimensions = new System.Drawing.SizeF( 6F, 13F );
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = cancelButton;
- this.ClientSize = new System.Drawing.Size( 459, 250 );
- this.Controls.Add( this.tableLayoutPanel1 );
+ this.ClientSize = new System.Drawing.Size(459, 250);
+ this.Controls.Add(this.tableLayoutPanel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
this.Name = "EquationEditor";
this.Text = "Formula Editor";
- this.tableLayoutPanel1.ResumeLayout( false );
+ this.tableLayoutPanel1.ResumeLayout(false);
this.tableLayoutPanel1.PerformLayout();
- this.flowLayoutPanel1.ResumeLayout( false );
+ this.flowLayoutPanel1.ResumeLayout(false);
this.flowLayoutPanel1.PerformLayout();
- this.tableLayoutPanel2.ResumeLayout( false );
- ((System.ComponentModel.ISupportInitialize) (this.formulaPreview)).EndInit();
- this.panel1.ResumeLayout( false );
+ this.tableLayoutPanel2.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.formulaPreview)).EndInit();
+ this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
- ((System.ComponentModel.ISupportInitialize) (this.fontSizeUpDown)).EndInit();
- this.ResumeLayout( false );
+ ((System.ComponentModel.ISupportInitialize)(this.fontSizeUpDown)).EndInit();
+ this.ResumeLayout(false);
}
diff --git a/PowerPointLaTeX/PowerPointLaTeX/Equations/EquationEditor.cs b/PowerPointLaTeX/PowerPointLaTeX/Equations/EquationEditor.cs
index 15139b1..7fd116d 100644
--- a/PowerPointLaTeX/PowerPointLaTeX/Equations/EquationEditor.cs
+++ b/PowerPointLaTeX/PowerPointLaTeX/Equations/EquationEditor.cs
@@ -29,8 +29,9 @@
using System.Diagnostics;
namespace PowerPointLaTeX {
- public partial class EquationEditor : Form {
+ partial class EquationEditor : Form {
private System.Timers.Timer updatePreviewTimer;
+ LocalCache localCache;
public String LaTeXCode {
get { return formulaText.Text; }
@@ -40,11 +41,11 @@
get { return (int) fontSizeUpDown.Value; }
}
- private string lastRenderedLaTeXCode = "";
-
- public EquationEditor(String latexCode, int initialFontSize) {
+ public EquationEditor(ICacheStorage masterStorage, String latexCode, int initialFontSize) {
InitializeComponent();
+ localCache = new LocalCache(masterStorage);
+
updatePreviewTimer = new System.Timers.Timer();
updatePreviewTimer.Interval = 0.5 * 1000;
updatePreviewTimer.AutoReset = false;
@@ -63,11 +64,6 @@
private void updatePreview() {
UseWaitCursor = true;
- // release the old cache entry if there was one
- if( lastRenderedLaTeXCode != "" ) {
- lastRenderedLaTeXCode = "";
- }
-
formulaPreview.Image = null;
if( LaTeXCode != "" ) {
@@ -75,7 +71,7 @@
int unusedBaselineOffset;
float wantedPixelsPerEmHeight = DPIHelper.FontSizeToPixelsPerEmHeight((float)fontSizeUpDown.Value);
float actualPixelsPerEmHeight = wantedPixelsPerEmHeight;
- previewImage = LaTeXRendering.GetImageForLaTeXCode( LaTeXCode, ref actualPixelsPerEmHeight, out unusedBaselineOffset );
+ previewImage = LaTeXRendering.GetImageForLaTeXCode( localCache, LaTeXCode, ref actualPixelsPerEmHeight, out unusedBaselineOffset );
formulaPreview.Image = previewImage;
formulaPreview.Height = (int) (previewImage.Height * wantedPixelsPerEmHeight / actualPixelsPerEmHeight);
@@ -83,8 +79,6 @@
formulaPreview.Top = 0;
formulaPreview.Left = (tableLayoutPanel2.Width - formulaPreview.Width) / 2;
-
- lastRenderedLaTeXCode = LaTeXCode;
}
UseWaitCursor = false;
@@ -104,5 +98,12 @@
updatePreviewTimer.Stop();
updatePreviewTimer.Start();
}
+
+ private void applyButton_Click(object sender, EventArgs e)
+ {
+ if( localCache.MasterStorage != null ) {
+ localCache.MasterStorage.Set(LaTeXCode, localCache.Get(LaTeXCode));
+ }
+ }
}
}
diff --git a/PowerPointLaTeX/PowerPointLaTeX/Equations/EquationHandling.cs b/PowerPointLaTeX/PowerPointLaTeX/Equations/EquationHandling.cs
index e934daf..f02f4c3 100644
--- a/PowerPointLaTeX/PowerPointLaTeX/Equations/EquationHandling.cs
+++ b/PowerPointLaTeX/PowerPointLaTeX/Equations/EquationHandling.cs
@@ -31,7 +31,7 @@
}
static public Shape EditEquation( Shape equation, out bool cancelled ) {
- EquationEditor editor = new EquationEditor( equation.LaTeXTags().Code, equation.LaTeXTags().FontSize );
+ EquationEditor editor = new EquationEditor( LaTeXTool.ActivePresentation.CacheTags(), equation.LaTeXTags().Code, equation.LaTeXTags().FontSize );
DialogResult result = editor.ShowDialog();
if( result == DialogResult.Cancel ) {
cancelled = true;
diff --git a/PowerPointLaTeX/PowerPointLaTeX/LaTeXRendering/ILaTeXRenderingService.cs b/PowerPointLaTeX/PowerPointLaTeX/LaTeXRendering/ILaTeXRenderingService.cs
index 7e32cd4..0a8abb4 100644
--- a/PowerPointLaTeX/PowerPointLaTeX/LaTeXRendering/ILaTeXRenderingService.cs
+++ b/PowerPointLaTeX/PowerPointLaTeX/LaTeXRendering/ILaTeXRenderingService.cs
@@ -28,6 +28,11 @@
{
public struct LaTeXCompilationTask
{
+ /// <summary>
+ /// (from the dvipng manpage)
+ /// It reports the number of pixels from the bottom of the image to the baseline of the image.
+ /// The depth is a negative offset in this case, so the minus sign is necessary, and the unit is pixels (px).
+ /// </summary>
public string code;
/// <summary>
@@ -65,10 +70,7 @@
/// </summary>
/// <param name="latexCode"></param>
/// <param name="image">the actual image of the rendered latexCode</param>
- /// <param name="baselineOffset"> (from the dvipng manpage)
- /// It reports the number of pixels from the bottom of the image to the baseline of the image.
- /// This can be used for vertical positioning of the image in, e.g., web documents, where one would use (Cascading StyleSheets 1)
- /// The depth is a negative offset in this case, so the minus sign is necessary, and the unit is pixels (px).
+ /// <param name="baselineOffset">
/// </param>
/// <returns>returns false if there was an error</returns>
LaTeXCompilationResult RenderLaTeXCode(LaTeXCompilationTask task);
diff --git a/PowerPointLaTeX/PowerPointLaTeX/LaTeXRendering/LaTeXRendering.cs b/PowerPointLaTeX/PowerPointLaTeX/LaTeXRendering/LaTeXRendering.cs
index c6da863..9ccb958 100644
--- a/PowerPointLaTeX/PowerPointLaTeX/LaTeXRendering/LaTeXRendering.cs
+++ b/PowerPointLaTeX/PowerPointLaTeX/LaTeXRendering/LaTeXRendering.cs
@@ -45,7 +45,8 @@
int baselineOffset;
float wantedPixelsPerEmHeight = DPIHelper.FontSizeToPixelsPerEmHeight(fontSize, DPIHelper.WindowsDPISetting);
float actualPixelsPerEmHeight = DPIHelper.FontSizeToPixelsPerEmHeight(fontSize, RenderDPISetting);
- Image image = GetImageForLaTeXCode(latexCode, ref actualPixelsPerEmHeight, out baselineOffset);
+ CacheTags presentationCache = LaTeXTool.ActivePresentation.CacheTags();
+ Image image = GetImageForLaTeXCode(presentationCache, latexCode, ref actualPixelsPerEmHeight, out baselineOffset);
if (image == null)
{
return null;
@@ -112,9 +113,9 @@
return pictureRange[1];
}
- static public Image GetImageForLaTeXCode(string latexCode, ref float pixelsPerEmHeight, out int baselineOffset)
+ static public Image GetImageForLaTeXCode(ICacheStorage cacheStorage, string latexCode, ref float pixelsPerEmHeight, out int baselineOffset)
{
- byte[] imageData = GetImageDataForLaTeXCode(latexCode, ref pixelsPerEmHeight, out baselineOffset);
+ byte[] imageData = GetImageDataForLaTeXCode(cacheStorage, latexCode, ref pixelsPerEmHeight, out baselineOffset);
return GetImageFromImageData(imageData);
}
@@ -124,16 +125,14 @@
/// </summary>
/// <param name="latexCode"></param>
/// <returns></returns>
- static private byte[] GetImageDataForLaTeXCode(string latexCode, ref float pixelsPerEmHeight, out int baselineOffset)
+ static private byte[] GetImageDataForLaTeXCode(ICacheStorage cacheStorage, string latexCode, ref float pixelsPerEmHeight, out int baselineOffset)
{
- // TODO: this is very much a hack! (to allow everything to stay static) [9/22/2010 Andreas]
- CacheTags presentationCache = LaTeXTool.ActivePresentation.CacheTags();
-
- CacheEntry? cacheEntry = Cache.Query(presentationCache, latexCode);
+ CacheEntry? cacheEntry = Cache.Query(cacheStorage, latexCode);
// TODO: rewrite the cache system to work even if the main thread is blocked [8/4/2009 Andreas]
if (cacheEntry.HasValue)
{
- // make sure we return a some-what meaningful array
+ // don't return a malformed cache entry
+ // TODO: move this check somewhere else? [12/11/2010 Andreas]
if (cacheEntry.Value.Content == null || cacheEntry.Value.Content.Length == 0)
{
cacheEntry = null;
@@ -164,12 +163,12 @@
if (entry.Content != null && entry.Content.Length > 0)
{
// looks good, so cache it
- Cache.Store(presentationCache, latexCode, entry);
+ Cache.Store(cacheStorage, latexCode, entry);
}
else
{
// if this failed, use the result from the cache, can't be off worse
- entry = cacheEntry.Value;
+ entry = cacheEntry.GetValueOrDefault();
}
}