DrawCautionIcon raises exception but I do not use it anywhere

Hello,
I am experiencing a strange issue where I get crash reports from my app running on windows, with Unhandled Exceptions raised from DrawCautionIcon, but I don’t use this method anywhere in my project and also from the stack traces in the crash reports nothing points to something that may use it.
I am not able to reproduce the problem myself but I see some of the user is experiencing it.
Exceptions raised are of two kinds:

  • UnsupportedOperationException with message “Graphics object cannot be used outside its Paint event”. Stack Trace:
    RuntimeRaiseException
    RuntimeExceptionStack
    RuntimeExceptionStack
    graphicsDrawCautionIcon
    Graphics.DrawCautionIcon%%of8f8
    SCProjectAssetsLibraryWidget.SCProjectAssetsLibraryWidget.importDroppedObjects%%o<SCProjectAssetsLibraryWidget.SCProjectAssetsLibraryWidget>o
    SCProjectAssetsLibraryWidget.SCProjectAssetsLibraryWidget.Event_DropObject%%o<SCProjectAssetsLibraryWidget.SCProjectAssetsLibraryWidget>oi8
    ewcDropObject
    EmbeddedWindowControl.Event_DropObject%%ooi8
    EmbedWithinInternal
    HideMouseCursor
    serialClearBreak
    selectColor
    RevokeActiveObjectExt
    NdrSendReceive
    Ndr64AsyncServerCallAll
    NdrStubCall3
    CStdStubBuffer_Invoke
    CoWaitForMultipleObjects
    CoWaitForMultipleObjects
    HSTRING_UserSize
    CoGetCurrentLogicalThreadId
    CoWaitForMultipleHandles
    CoSetErrorInfo
    CoGetStandardMarshal
    CallWindowProcW
    DispatchMessageW
    enableMenuItems
    Application._CallFunctionWithExceptionHandling%%op
    enableMenuItems
    RuntimeRun
    REALbasic._RuntimeRun
    _Main
    wWinMain
    __tmainCRTStartup
    BaseThreadInitThunk
    RtlUserThreadStart

  • NilObjectException with message “Graphics has no backing, most likely its associated Picture has been destroyed”. Stack Trace:
    RuntimeRaiseException
    RuntimeExceptionStack
    graphicsDrawCautionIcon
    Graphics.DrawCautionIcon%%of8f8
    SCStage.handleDragOver%%oi8i8oi8
    ProjectWinDragCatcherWin.ProjectWinDragCatcherWin.mainStageDragEventsManager_DragOver%b%o<ProjectWinDragCatcherWin.ProjectWinDragCatcherWin>oi8i8oi8
    Delegate.IM_Invoke%b%oi8i8i8i8
    AddHandler.Stub.7%b%i8i8oi8
    EmbedWithinInternal
    HideMouseCursor
    serialClearBreak
    selectColor
    RevokeActiveObjectExt
    NdrSendReceive
    Ndr64AsyncServerCallAll
    NdrStubCall3
    CStdStubBuffer_Invoke
    Ordinal111
    Ordinal111
    HSTRING_UserSize
    StringFromGUID2
    RoGetApartmentIdentifier
    CoRegisterClassObject
    Ordinal87
    CallWindowProcW
    DispatchMessageW
    enableMenuItems
    Application._CallFunctionWithExceptionHandling%%op
    enableMenuItems
    RuntimeRun
    REALbasic._RuntimeRun
    _Main
    wWinMain
    __tmainCRTStartup
    BaseThreadInitThunk
    RtlUserThreadStart

Again, searching my project for “DrawCautionIcon” gives zero results. Also on the Mac, using of course the same code, this never happens.

Any ideas?

App is compiled with Xojo 2020r2.1

Look in

mainStageDragEventsManager.DragOver

Do you happen to call MsgBox or MessageBox or use a MessageDialog in there?

Hello Greg,
no, that simply calls handleDragOver, which does not call MsgBox or similar.

I wonder if the DrawCautionIcon message is misleading and not really having anything to do with DrawCautionIcon. Perhaps you are calling a routine during the Close process that tries to access a Canvas’s or Picture’s Graphics object after it has been destroyed or gone out of scope. Xojo does have some misleading error messages.

What is the code in ‘importDroppedObjects’?