Gerald Brandt
2014-02-13 04:16:24 UTC
Hi,
I have an app that potentially does a lot of font stuff every key press. Basically all it does is GetTextExtent in order to perform word wrapping.
At times, the app can take multiple seconds to do its work. I decided to move my font measurement into a thread to help free up the main GUI.
Knowing some stuff wouldn't work in a thread, I created wxCommandEvents to pass some work back to the main process. In the event loop, I do this:
void cEditorCtrl::OnLayoutSetBaseFont(wxCommandEvent &event)
{
UNUSED_ARGUMENT(event) ;
cEditorRender *render = mLayouts[mUseLayout] ;
wxFont font = render->GetBaseFont() ; // get the base font of the editor
if(mWordWrap == true)
{
font.Scale(render->mFontScale) ;
}
mLayoutDC.SelectObject(mLayoutBitmap) ;
mLayoutDC.SetFont(font) ;
}
to set a base font for the DC. mLayoutBitmap and mLayoutDC are created in the class.
I get a gtk error on the SetFont... occasionally. I'm guaranteed a crash if I hold down a key, calling this event handler for every keystroke. The error is:
(WordTsar:12826): Gtk-CRITICAL **: IA__gtk_text_attributes_ref: assertion 'values != NULL' failed
(WordTsar:12826): Gtk-CRITICAL **: IA__gtk_text_attributes_ref: assertion 'values != NULL' failed
WordTsar: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.
Any idea why this happens?
Gerald
ps: I moved the SelectObject into the class Init, and got a different error, usually at the same rate as mentioned above:
*** Error in `./WordTsar': double free or corruption (fasttop): 0x00007fd78c008ed0 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x80996)[0x7fd7a0bd8996]
/usr/lib/x86_64-linux-gnu/libpango-1.0.so.0(pango_font_description_free+0x2e)[0x7fd7a272bc4e]
./WordTsar[0x6040a3]
./WordTsar[0x445864]
./WordTsar[0x45b5db]
./WordTsar[0x4ab79e]
./WordTsar[0x4aa8e7]
./WordTsar[0x4aa561]
./WordTsar[0x4aa428]
./WordTsar[0x4aa22f]
./WordTsar[0x7842e9]
./WordTsar[0x784c40]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x7f6e)[0x7fd7a0f27f6e]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x7fd7a0c529cd]
I have an app that potentially does a lot of font stuff every key press. Basically all it does is GetTextExtent in order to perform word wrapping.
At times, the app can take multiple seconds to do its work. I decided to move my font measurement into a thread to help free up the main GUI.
Knowing some stuff wouldn't work in a thread, I created wxCommandEvents to pass some work back to the main process. In the event loop, I do this:
void cEditorCtrl::OnLayoutSetBaseFont(wxCommandEvent &event)
{
UNUSED_ARGUMENT(event) ;
cEditorRender *render = mLayouts[mUseLayout] ;
wxFont font = render->GetBaseFont() ; // get the base font of the editor
if(mWordWrap == true)
{
font.Scale(render->mFontScale) ;
}
mLayoutDC.SelectObject(mLayoutBitmap) ;
mLayoutDC.SetFont(font) ;
}
to set a base font for the DC. mLayoutBitmap and mLayoutDC are created in the class.
I get a gtk error on the SetFont... occasionally. I'm guaranteed a crash if I hold down a key, calling this event handler for every keystroke. The error is:
(WordTsar:12826): Gtk-CRITICAL **: IA__gtk_text_attributes_ref: assertion 'values != NULL' failed
(WordTsar:12826): Gtk-CRITICAL **: IA__gtk_text_attributes_ref: assertion 'values != NULL' failed
WordTsar: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.
Any idea why this happens?
Gerald
ps: I moved the SelectObject into the class Init, and got a different error, usually at the same rate as mentioned above:
*** Error in `./WordTsar': double free or corruption (fasttop): 0x00007fd78c008ed0 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x80996)[0x7fd7a0bd8996]
/usr/lib/x86_64-linux-gnu/libpango-1.0.so.0(pango_font_description_free+0x2e)[0x7fd7a272bc4e]
./WordTsar[0x6040a3]
./WordTsar[0x445864]
./WordTsar[0x45b5db]
./WordTsar[0x4ab79e]
./WordTsar[0x4aa8e7]
./WordTsar[0x4aa561]
./WordTsar[0x4aa428]
./WordTsar[0x4aa22f]
./WordTsar[0x7842e9]
./WordTsar[0x784c40]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x7f6e)[0x7fd7a0f27f6e]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x7fd7a0c529cd]
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users