Hello,I create the application with the FLTK library. Almost everything works as it should, except one important thing, and I couldn't find the right solution so far. Random artifacts appear in the window. They also appear randomly - sometimes everything is displayed correctly, but sometimes there are strange lines, some parts of the controls are not refreshed etc. I tried to use Fl::check() but it didn't help in every case. Please see the included examples (a strange black line over the window, a strange blue line over the button, and a broken frame around the button). How can I avoid these problems?
On Wed, 6 Jul 2022 at 11:54, Jck_01 wrote:Hello,I create the application with the FLTK library. Almost everything works as it should, except one important thing, and I couldn't find the right solution so far. Random artifacts appear in the window. They also appear randomly - sometimes everything is displayed correctly, but sometimes there are strange lines, some parts of the controls are not refreshed etc. I tried to use Fl::check() but it didn't help in every case. Please see the included examples (a strange black line over the window, a strange blue line over the button, and a broken frame around the button). How can I avoid these problems?We'd probably have to see some code to tell, but to me it looks like you are drawing outside the valid context.Hmm; Is this on Windows?
The order and setting of the "pens" in Windows is a bit sensitive, so you need to ensure you do that in the correct order too. I think that is discussed in the docs, FWIW.Maybe you can post a small, compile-able example that shows what you are doing that gets this effect?
I was rather hoping to dee more of your widget code and in particular
what you are doing for draw() methods, that sort of thing.
How many threads are in your code?
How many threads are in your code?
Generally only one. The code in dialog windows uses one, main program thread. A new thread is created only when I call methods of network library. Could it be the reason of artefacts?
On 6 Jul 2022, at 18:04, Jck_01 <projekt...@gmail.com> wrote:
--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/12b02a13-f934-4f1d-bd94-6a15501de17dn%40googlegroups.com.
Generally not if you don't call FLTK methods from within your thread code.
Here's another question: Did you recently update your FLTK repo / working copy? Maybe even switching from 1.3 to 1.4 ?
That sounds most curious - if the async call is not interacting with fltk at all, I’d expect it to be “safe”, so this is unexpected. Does it (the async method) interact with the GUI context in some way, or something?
It might be useful if you could show us the code for the callback, in case something useful occurs to anyone on seeing it...
void GUIDlgNetClient::connectToServer(void)
{
srvIPAddressInput->deactivate();
srvPortInput->deactivate();
netMessages->value(u8"");
addMessage(gui.getTranslation().Translate(u8"Connecting to server..."));
Fl::check();
int ret = gui.getNet().getClient().start();if (ret != Network::NET_OK){
addMessage(GUI::translateErrorCode(ret));
if (gui.getNet().getClient().isActive())
gui.getNet().getClient().stop();
}
else
{
addMessage(gui.getTranslation().Translate(u8"Connected!").c_str());
{
addMessage(gui.getTranslation().Translate(u8"Connected!").c_str());Just an idea, but maybe the problem is here ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^. Maybe it operates on temporary objects or takes the pointer produced by c_str() and the problem is in the pointer handling? Just guessing.
And this all happens in the context of the main() thread?
For example, it is never safe to call Fl::check(); from any non-main
thread context.
Actually, if this is all happening in the callback, I'd not call
Fl::check(); at all anyway, TBH.