I’m writing a little program with a GUI interface that launches several sorting algorithms ported in Haxe. I launched the main loop inside a thread and, to avoid double clicks on the “run” button, I disable the button before the loop and re-enable it ounce the loop is over. I also use a label as a kind of status bar to show the current algorithm being processed. Since hxWidgets is compiled in C++, it’s very quick and for a few elements to order the program terminates the work in a short time. This causes the GUI not to be refreshed properly: the label I use to show the current algorithm isn’t set to the default “ready” message, while the button is. While, if I use a lot of items, the GUI seems to have to proper time to process the events and reset the label to “ready”. Occasionally, I also get some segmentation fault errors, and a couple of other errors I got today. The first one:
Debug: window wxButton@0x5d2c08f8c0f0 ("Run") lost focus even though it didn't have it
The second one:
**
Gtk:ERROR:../gtk/gtk/gtkcssnode.c:319:lookup_in_global_parent_cache: assertion failed: (node->cache == NULL)
Bail out! Gtk:ERROR:../gtk/gtk/gtkcssnode.c:319:lookup_in_global_parent_cache: assertion failed: (node->cache == NULL)
zsh: IOT instruction (core dumped) ./Main
This is the portion of the code that calls the main loop:
private function launchApp() {
var thread = Thread.create(function() {
runTest();
});
}
private function runTest() {
btnRun.disabled = true;
sortTesting();
btnRun.disabled = false;
statusBar.text = "Ready";
private function sortTesting() {
// ....cut here....
for (i in 0...sortingAlgorithms.length) {
var algName = sortingAlgorithms[i].get_name();
statusBar.text = ("Running " + algName + "...");
// ... cut here.....
The strange thing is that the button is properly re-enabled even though the loop takes a very short time while the label is set to the default value only if the loop is long enough to do the change, otherwise keep the last change made in the loop.
Is there a way to force the GUI to “flush” all the pending changes to the various widgets?
Thank you