User forums > General (but related to Code::Blocks)

C::B with DirectWrite enabled will crash when in Windows remote desktop

(1/3) > >>

I see this crash, if I enabled DirectWrite, and I first close the remote desktop, and keep C::B running in the remote PC. And later if I open the remote desktop, the C::B will crash.

Here is the crash call stack I got from the remotePC's gdb.

--- Code: ---[debug]#0  0x000007fee5120f2d in ID2D1RenderTarget::DrawBitmap (this=0x0, bitmap=0xa5a15f0, destinationRectangle=..., opacity=1, interpolationMode=D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, sourceRectangle=...) at D:\code\msys2\mingw64\include\d2d1.h:904
[debug]#1  0x000007fee4f5dc75 in SurfaceD2D::Copy (this=0xa771040, rc=..., from=..., surfaceSource=...) at D:\code\cbsource\cb_svn_git\src\sdk\wxscintilla\src\PlatWX.cpp:1523
[debug]#2  0x000007fee5039b18 in EditView::PaintText (this=0xa4d5ec0, surfaceWindow=0xa771040, model=..., rcArea=..., rcClient=..., vsDraw=...) at D:\code\cbsource\cb_svn_git\src\sdk\wxscintilla\src\scintilla\src\EditView.cxx:2096
[debug]#3  0x000007fee5011c0b in Editor::Paint (this=0xa4d5910, surfaceWindow=0xa771040, rcArea=...) at D:\code\cbsource\cb_svn_git\src\sdk\wxscintilla\src\scintilla\src\Editor.cxx:1762
[debug]#4  0x000007fee4f64f37 in ScintillaWX::DoPaint (this=0xa4d5910, dc=0x23eb90, rect=...) at D:\code\cbsource\cb_svn_git\src\sdk\wxscintilla\src\ScintillaWX.cpp:918
[debug]#5  0x000007fee4f54dad in wxScintilla::OnPaint (this=0xa4d2910) at D:\code\cbsource\cb_svn_git\src\sdk\wxscintilla\src\wxscintilla.cpp:5234
[debug]#6  0x000007feea2d2e77 in wxAppConsoleBase::CallEventHandler(wxEvtHandler*, wxEventFunctor&, wxEvent&) const () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
[debug]#7  0x000007feea422aa5 in wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
[debug]#8  0x000007feea422c8b in wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
[debug]#9  0x000007feea4232cd in wxEvtHandler::TryHereOnly(wxEvent&) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
[debug]#10 0x000007feea423343 in wxEvtHandler::ProcessEventLocally(wxEvent&) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
[debug]#11 0x000007feea423421 in wxEvtHandler::ProcessEvent(wxEvent&) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
[debug]#12 0x000007feea424edb in wxEvtHandler::SafelyProcessEvent(wxEvent&) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
[debug]#13 0x000007feea5289d8 in wxWindow::HandlePaint() () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
[debug]#14 0x000007feea52aa68 in wxWindow::MSWHandleMessage(long long*, unsigned int, unsigned long long, long long) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
[debug]#15 0x000007feea515efc in wxWindow::MSWWindowProc(unsigned int, unsigned long long, long long) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
[debug]#16 0x0000000077008975 in USER32!GetWindowDC () from C:\Windows\system32\user32.dll
[debug]#17 0x000000007700729b in USER32!SetWindowTextW () from C:\Windows\system32\user32.dll
[debug]#18 0x00000000770067e9 in USER32!IsDialogMessageW () from C:\Windows\system32\user32.dll
[debug]#19 0x000000007729b5cf in ntdll!KiUserCallbackDispatcher () from C:\Windows\SYSTEM32\ntdll.dll
[debug]#20 0x0000000077006e2a in USER32!BeginPaint () from C:\Windows\system32\user32.dll
[debug]#21 0x0000000077006e3c in USER32!BeginPaint () from C:\Windows\system32\user32.dll
[debug]#22 0x0000000077006782 in USER32!IsDialogMessageW () from C:\Windows\system32\user32.dll
[debug]#23 0x000007feea519330 in wxWindow::MSWSafeIsDialogMessage(tagMSG*) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
[debug]#24 0x000007feea5195d9 in wxWindow::MSWProcessMessage(tagMSG*) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
[debug]#25 0x000007feea54a4a0 in wxGUIEventLoop::PreProcessMessage(tagMSG*) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
[debug]#26 0x000007feea54a7ef in wxGUIEventLoop::Dispatch() () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
[debug]#27 0x000007feea3047e3 in wxEventLoopManual::ProcessEvents() () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
[debug]#28 0x000007feea3048f8 in wxEventLoopManual::DoRun() () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
[debug]#29 0x000007feea3045c8 in wxEventLoopBase::Run() () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
[debug](More stack frames follow...)

--- End code ---

The problem is that the "this" pointer is 0.

when calling the function:

--- Code: ---    void DrawBitmap(ID2D1Bitmap *bitmap, const D2D1_RECT_F &destinationRectangle, FLOAT opacity, D2D1_BITMAP_INTERPOLATION_MODE interpolationMode, const D2D1_RECT_F &sourceRectangle) {
        DrawBitmap(bitmap, &destinationRectangle, opacity, interpolationMode, &sourceRectangle);
--- End code ---

Which means the "m_pRenderTarget" will be 0.

In the function:

--- Code: ---void SurfaceD2D::Copy(PRectangle rc, Point from, Surface &surfaceSource) {
    SurfaceD2D &surfOther = static_cast<SurfaceD2D &>(surfaceSource);

    wxCOMPtr<ID2D1Bitmap> pBitmap;
    wxCOMPtr<ID2D1BitmapRenderTarget> pCompatibleRenderTarget(

    HRESULT hr = pCompatibleRenderTarget->GetBitmap(&pBitmap);

    if ( SUCCEEDED(hr) )
        D2D1_RECT_F rcDestination = {rc.left,, rc.right, rc.bottom};
        D2D1_RECT_F rcSource =
            {from.x, from.y, from.x + rc.Width(), from.y + rc.Height()};
        m_pRenderTarget->DrawBitmap(pBitmap, rcDestination, 1.0f,

        hr = m_pRenderTarget->Flush();
        if ( FAILED(hr) )
            Platform::DebugPrintf("Failed Flush 0x%x\n", hr);

--- End code ---

I have reported this kind of crash before, but I have never try to get the call stack of the crash.

So scintilla or wxWidgets bug?


--- Quote from: BlueHazzard on October 13, 2022, 04:24:37 pm ---So scintilla or wxWidgets bug?

--- End quote ---

I think it is in our wxscintilla in cb code base.

I don't see the crash issue when using Notepad++. Please note that Notepad++ has direct2d enabled.

I just checked... Are we really using version 3.7.5. of scintilla?
I think we should update....
scintilla in wxWidgets seems to be 3.7.2 and official scintilla version is 5.3.1

there could be tons of improvements...

> Added change history which can display document changes (modified, saved, ...) in the margin or in the text.
we probably could also remove some of our own code in favour of this... As far as i know the change bar is our own implementation...

Miguel Gimenez:
Following this tutorial it says:

--- Quote ---Your application should create render targets once and hold on to them for the life of the application or until the D2DERR_RECREATE_TARGET error is received. When you receive this error, you need to recreate the render target (and any resources it created).
--- End quote ---


[0] Message Index

[#] Next page

Go to full version