Changeset 1660


Ignore:
Timestamp:
1/25/2010 2:42:53 AM (5 years ago)
Author:
lowjoel
Message:

Forward Port from Eraser 6.0: When dealing with the LogForm? and the ProgressForm? classes, for events in which we wait for triggering by the task object, we should check that the form we belong to exists (i.e. not disposed) before we do anything on the form since forms which have Disposed() called will still receive events. There is a fix removed in this revision (in ProgressForm?.cs/WrapItemName) which may introduce new bugs but since this is really hard to reproduce I'll commit a blind fix and wait for more reports to come in.

Location:
trunk/eraser6
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/eraser6

  • trunk/eraser6/Eraser/LogForm.cs

    r1450 r1660  
    7777        private void task_NewSession(object sender, EventArgs e) 
    7878        { 
     79            if (!IsHandleCreated) 
     80                return; 
    7981            if (InvokeRequired) 
    8082            { 
     
    8890        private void task_Logged(object sender, LogEventArgs e) 
    8991        { 
     92            if (!IsHandleCreated) 
     93                return; 
    9094            if (InvokeRequired) 
    9195            { 
  • trunk/eraser6/Eraser/ProgressForm.cs

    r1515 r1660  
    6767        private void task_ProgressChanged(object sender, ProgressChangedEventArgs e) 
    6868        { 
     69            if (!IsHandleCreated) 
     70                return; 
    6971            if (InvokeRequired) 
    7072            { 
     
    9193        private void task_TaskFinished(object sender, TaskEventArgs e) 
    9294        { 
     95            if (!IsHandleCreated) 
     96                return; 
    9397            if (InvokeRequired) 
    9498            { 
     
    184188        { 
    185189            StringBuilder result = new StringBuilder(itemName.Length); 
    186  
    187             try 
    188             { 
    189                 using (Graphics g = item.CreateGraphics()) 
     190            using (Graphics g = item.CreateGraphics()) 
     191            { 
     192                //Split the long file name into lines which fit into the width of the label 
     193                while (itemName.Length > 0) 
    190194                { 
    191                     //Split the long file name into lines which fit into the width of the label 
    192                     while (itemName.Length > 0) 
    193                     { 
    194                         int chars = 0; 
    195                         int lines = 0; 
    196                         g.MeasureString(itemName, item.Font, new SizeF(item.Width - 2, 15), 
    197                             StringFormat.GenericDefault, out chars, out lines); 
    198  
    199                         result.AppendLine(itemName.Substring(0, chars)); 
    200                         itemName = itemName.Remove(0, chars); 
    201                     } 
     195                    int chars = 0; 
     196                    int lines = 0; 
     197                    g.MeasureString(itemName, item.Font, new SizeF(item.Width - 2, 15), 
     198                        StringFormat.GenericDefault, out chars, out lines); 
     199 
     200                    result.AppendLine(itemName.Substring(0, chars)); 
     201                    itemName = itemName.Remove(0, chars); 
    202202                } 
    203             } 
    204             catch (ObjectDisposedException) 
    205             { 
    206                 //Called when the user closes the form and the delegate call to Invoke was queued. 
    207203            } 
    208204 
Note: See TracChangeset for help on using the changeset viewer.