fix condvar and dialog window content area newapi

Wed, 23 Oct 2024 17:16:51 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 23 Oct 2024 17:16:51 +0200
branch
newapi
changeset 349
d188f52cff7f
parent 348
a4fdec2fc353
child 350
70305d427f25

fix condvar and dialog window content area

ui/common/condvar.c file | annotate | diff | comparison | revisions
ui/common/condvar.h file | annotate | diff | comparison | revisions
ui/gtk/window.c file | annotate | diff | comparison | revisions
--- a/ui/common/condvar.c	Wed Oct 23 16:34:08 2024 +0200
+++ b/ui/common/condvar.c	Wed Oct 23 17:16:51 2024 +0200
@@ -34,6 +34,7 @@
     UiPosixCondVar *var = malloc(sizeof(UiPosixCondVar));
     var->var.data = NULL;
     var->var.intdata = 0;
+    var->set = 0;
     pthread_mutex_init(&var->lock, NULL);
     pthread_cond_init(&var->cond, NULL);
     return (UiCondVar*)var;
@@ -42,7 +43,10 @@
 void ui_condvar_wait(UiCondVar *var) {
     UiPosixCondVar *p = (UiPosixCondVar*)var;
     pthread_mutex_lock(&p->lock);
-    pthread_cond_wait(&p->cond, &p->lock);
+    if(!p->set) {
+        pthread_cond_wait(&p->cond, &p->lock);
+    }
+    p->set = 0;
     pthread_mutex_unlock(&p->lock);
     
 }
@@ -52,6 +56,7 @@
     pthread_mutex_lock(&p->lock);
     p->var.data = data;
     p->var.intdata = intdata;
+    p->set = 1;
     pthread_cond_signal(&p->cond);
     pthread_mutex_unlock(&p->lock);
 }
--- a/ui/common/condvar.h	Wed Oct 23 16:34:08 2024 +0200
+++ b/ui/common/condvar.h	Wed Oct 23 17:16:51 2024 +0200
@@ -39,6 +39,7 @@
 
 typedef struct UiPosixCondVar {
     UiCondVar var;
+    int set;
     pthread_mutex_t lock;
     pthread_cond_t cond;
 } UiPosixCondVar;
--- a/ui/gtk/window.c	Wed Oct 23 16:34:08 2024 +0200
+++ b/ui/gtk/window.c	Wed Oct 23 17:16:51 2024 +0200
@@ -700,6 +700,7 @@
                     WIDGET_ADD_CSS_CLASS(button, "suggested-action");
                 }
             }
+            WINDOW_SET_CONTENT(obj->widget, content_vbox);
             return obj;
         }
 #endif

mercurial