Changeset 1659


Ignore:
Timestamp:
01/25/10 02:35:37 (5 years ago)
Author:
lowjoel
Message:

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:
branches/eraser6/6.0/Eraser
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/6.0/Eraser/LogForm.cs

    r1360 r1659  
    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            { 
  • branches/eraser6/6.0/Eraser/ProgressForm.cs

    r1360 r1659  
    6161        private void task_ProgressChanged(object sender, TaskProgressEventArgs e) 
    6262        { 
     63            if (!IsHandleCreated) 
     64                return; 
    6365            if (InvokeRequired) 
    6466            { 
     
    102104        private void task_TaskFinished(object sender, TaskEventArgs e) 
    103105        { 
     106            if (!IsHandleCreated) 
     107                return; 
    104108            if (InvokeRequired) 
    105109            { 
     
    160164        { 
    161165            StringBuilder result = new StringBuilder(itemName.Length); 
     166            using (Graphics g = item.CreateGraphics()) 
     167            { 
     168                //Split the long file name into lines which fit into the width of the label 
     169                while (itemName.Length > 0) 
     170                { 
     171                    int chars = 0; 
     172                    int lines = 0; 
     173                    g.MeasureString(itemName, item.Font, new SizeF(item.Width - 2, 15), 
     174                        StringFormat.GenericDefault, out chars, out lines); 
    162175 
    163             try 
    164             { 
    165                 using (Graphics g = item.CreateGraphics()) 
    166                 { 
    167                     //Split the long file name into lines which fit into the width of the label 
    168                     while (itemName.Length > 0) 
    169                     { 
    170                         int chars = 0; 
    171                         int lines = 0; 
    172                         g.MeasureString(itemName, item.Font, new SizeF(item.Width - 2, 15), 
    173                             StringFormat.GenericDefault, out chars, out lines); 
    174  
    175                         result.AppendLine(itemName.Substring(0, chars)); 
    176                         itemName = itemName.Remove(0, chars); 
    177                     } 
     176                    result.AppendLine(itemName.Substring(0, chars)); 
     177                    itemName = itemName.Remove(0, chars); 
    178178                } 
    179             } 
    180             catch (ObjectDisposedException) 
    181             { 
    182                 //Called when the user closes the form and the delegate call to Invoke was queued. 
    183179            } 
    184180 
Note: See TracChangeset for help on using the changeset viewer.