Bug Report CB4246
Visible to All Users

RED CROSS OF DEATH

created 18 years ago

We have deployed your control in several of our applications
Our users get the .net control error or what they call the "Red Cross of Death" too frequently. During busy periods this can be 2-3 times a day.
We are binding your grid to an object that inherits from BindingList
--All our updates are on the GUI thread
--We are using the ChangeNotification workaround we found on your web site, IE supress OnListChanged event when we know there are a lot of updates
This is the exception logged on one of the users PC's
Event Type:     Information
Event Source:     MWAM.EMS.Blotter
Event Category:     None
Event ID:     0
Date:          13/12/2006
Time:          09:09:09
User:          N/A
Description:
Object reference not set to an instance of an object. StrackTrace: at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.UpdateCellAppearance(GridCellInfo cell, Boolean always)
   at DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.DrawRegularRowCell(GridViewDrawArgs e, GridCellInfo ci)
   at DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.DrawRegularRow(GridViewDrawArgs e, GridDataRowInfo ri)
   at DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.DrawRow(GridViewDrawArgs e, GridRowInfo ri)
   at DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.DrawRows(GridViewDrawArgs e)
   at DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.DrawContents(GridViewDrawArgs e)
   at DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.Draw(ViewDrawArgs ee)
   at DevExpress.XtraGrid.Views.Base.BaseView.Draw(GraphicsCache e)
   at DevExpress.XtraGrid.GridControl.OnPaint(PaintEventArgs e)
   at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
   at System.Windows.Forms.Control.WmPaint(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at DevExpress.XtraEditors.Container.EditorContainer.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

Show previous comments (8)
DevExpress Support Team 18 years ago

    Could you please clarify your code relation (the onOrdersUpdated method call) to the grid and the exception? What does this method and when is it called? If possible, please provide us with a test project. You may wish to send the entire project to us and we will help you debug it. In this case, we'll need step-by-step instructions to reproduce the problem.
    Thank you,
    Nick

    SV SV
    Stephan Verbeeck 9 years ago

      I have reverse engineered the applied logic and in all cases there was 1 common factor that is the cause of errors:

      1. Object reference not set to an instance of an object.
      2. Object is currently in use elsewhere.

      The error is the introduction of "DevExpress.Utils.Text.FontsCache.GetFontCacheByFont(Graphics graphics, Font font)".
      This class shares windows fonts between threads and that is STRICTLY FORBIDDEN.   Windows usage of GDI resources (during paint message handling but also stuff like "DevExpress.Utils.Text.TextUtils.GetStringSize(Graphics g, String text, Font font, StringFormat stringFormat, Int32 maxWidth, Int32 maxHeight, IWordBreakProvider wordBreakProvider, Boolean& isCropped)") is restricted to the thread that has created the GDI resource.
      In other words: "Only the thread that has created a font or window may use it, all other threads are not allowed to send windows paint messages to those windows".  Measuring the size of a font in a window is also some type of paint action (although invisible because only the size of the painted text is returned).

      Solution (only one of both should be implemented):

      1. The class "Text.FontsCache" must add the current-thread-ID to the ID that is used to store the created font in the cache.
      2. Each thread must make its own instance of the class "Text.FontsCache".
      DevExpress Support Team 9 years ago

        Thank you for the feedback, Stephan. I have created a separate ticket on your behalf to discuss this problem further: FontsCache might be sharing GDI resources between different threads.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.