thread process can not change text buffer

2024-04-26 Thread merlin
I am an absolute beginner and I hardly understand the problem that @Isofruit code has solved. Bui I believe to have a similar problem in the code that I post here below. My question is: how can I add to textArea the same text it is echoed on console in miohttpd on the line echo "responding on po

thread process can not change text buffer

2023-12-03 Thread tissatussa
Thanks to @Isofruit and @Araq for the detailed and honest feedback. I appreciate a working example. I have to study this, i've not tested the code yet. To accomplish what i want, the way threads must (not) be used now becomes more clear - it was really hard to find a solution / setup for it, for

thread process can not change text buffer

2023-12-02 Thread Isofruit
I did some research and playing around to figure out how a client-server architecture with owlkettle could look like and it works pretty well with using threads and channels (As Araq pretty much suggested if I understood him correctly). Below the minimal example that I got to work. Basically y

thread process can not change text buffer

2023-12-02 Thread Isofruit
The AppState type gets generated by the viewable macro. It is a ref-type Strictly speaking 2 ref-types, one representing the state of the GTKWidget (AppState) and one representing the "new" state within owlkettle with all the values it got from elsewhere (App). For those curious, this is the ty

thread process can not change text buffer

2023-12-02 Thread tissatussa
@Araq : please don't be rude, i'm a beginner and i try to understand threads my way .. thus far, this project and Owlkettle example codes gives me new insight in many ways. > There is no point in debugging your program as it's wrong it probably is, but how and why ? Some users gave me nice inpu

thread process can not change text buffer

2023-12-02 Thread tissatussa
@thindil : thanks for this info .. it gives me input to search for answers, because certain terms are involved which are new to me .. your short text is really helpful.

thread process can not change text buffer

2023-12-02 Thread thindil
The problem is not within Owlkettle, but in the graphical stack. Almost every GUI library isn't thread-safe and can be updated only from its main thread. The only multithread libraries are Vulkan, DirectX 12 and Metal. Anything else will crash when you will try to update GUI from another thread.

thread process can not change text buffer

2023-12-01 Thread Araq
There is no point in debugging your program as it's wrong, but you don't listen.

thread process can not change text buffer

2023-12-01 Thread tissatussa
and here is the latest "unstable" version of the script : import std/[streams, os, osproc, strutils, strformat] import owlkettle viewable App: buffer: TextBuffer monospace: bool = false cursorVisible: bool = true editable: bool = true ac

thread process can not change text buffer

2023-12-01 Thread tissatussa
BTW. this is my compilation command in the root of the Owlkettle package : `nim c --threads:on --mm:arc --path:. ./examples/widgets/uci_v4.nim`

thread process can not change text buffer

2023-12-01 Thread Araq
There is no reason to assume that "compiler flag X" fixes your problem as you have no idea what you're doing. You need to use 2 channels: One that tells your chess engine what to do and one that tells your UI what to render. Setup these channels as global variables.

thread process can not change text buffer

2023-12-01 Thread tissatussa
further additions and improvement of my script are working, but not always .. i'm running a chess engine binary as a thread process and i catch its output while it's evaluating a chess position .. but the process isn't "stable" : a severe error may happen anytime ? I tried different chess binari

thread process can not change text buffer

2023-12-01 Thread tissatussa
FOUND IT !! @guzba : your suggestion `--mm:arc` being a compilation option did the trick ! i get a working binary, which indeed echoes "HELLO" after each 1000 ms sleep .. thank you very much ! i will mention your response in the concerning GitHub Issue.

thread process can not change text buffer

2023-12-01 Thread tissatussa
@guzba : i think i know what you mean, but it's all too tech for me .. can it bring insight when i copy your response to that Owlkettle developer ? I might forward the issue and your details to someone else ? I guess developers appreciate important bugs and ways to reproduce those ..

thread process can not change text buffer

2023-12-01 Thread guzba
You absolutely cannot conclude that Nim is the cause. Posting my recent Discord messages here: yeah there are many clear issues in eg this unfortunately: where is the type AppState? is it a ref object? if so, probl

thread process can not change text buffer

2023-12-01 Thread guzba
Assigning a string will cause the previous value to be freed. In this case, there is no lock so there is no way to know what threads will see what and certainly any threads that did not do the writing may see the old value and attempt to deref it after it was freed.

thread process can not change text buffer

2023-12-01 Thread tissatussa
@Araq : you state "I can confirm that owlkette's threading examples are terrible.." \- well, all of their widget examples compile and run fine, they give me great insight of Owlkettle workings .. my threading code can be used to change other properties, only their Text View widget has this probl

thread process can not change text buffer

2023-12-01 Thread tissatussa
@dissolved_girl : i think my code examples on those GitHub pages show the problem : the 2 code lines in the thread function are somehow causing the error, the value of app.buffer.text can not be changed. Can you reproduce the error ?

thread process can not change text buffer

2023-12-01 Thread dissolved_girl
Can you provide some better examples?

thread process can not change text buffer

2023-12-01 Thread Araq
I can confirm that owlkette's threading examples are terrible and it's not a Nim bug.

thread process can not change text buffer

2023-12-01 Thread tissatussa
i want to report a bug (?) in Nim which occurs when using a widget of Owlkettle (mainly a wrapper for GTK, based on Nim, to build GUIs). It's best to read my 2 detailed Issues at their GitHub page : first i did and this continued at