From e4b3b04f990ccd2b6f2c6c36dbe48949e33d0da5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Thu, 21 Jul 2005 12:59:23 +0000 Subject: [PATCH] Appearantly, there is a race condition when setting preferences, this fixes (one of) the crash(es?), but we should really fix the race condition, but I have no energy to get to know the code more. I'm thinking the PrefHandler class needs locking, since it is used everywhere, it is probably best to put the locking directly into the PrefHandler methods. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13789 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/terminal/PrefHandler.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/apps/terminal/PrefHandler.cpp b/src/apps/terminal/PrefHandler.cpp index 5367ebab9d..abc91fe022 100644 --- a/src/apps/terminal/PrefHandler.cpp +++ b/src/apps/terminal/PrefHandler.cpp @@ -224,12 +224,16 @@ PrefHandler::getRGB(const char *key) { int r, g, b; rgb_color col; - const char *s = mPrefContainer.FindString(key); - sscanf(s, "%d, %d, %d", &r, &g, &b); + if (const char *s = mPrefContainer.FindString(key)) { + sscanf(s, "%d, %d, %d", &r, &g, &b); + } else { + fprintf(stderr, "PrefHandler::getRGB(%s) - key not found\n", key); + r = g = b = 0; + } col.red = r; col.green = g; col.blue = b; - col.alpha = 0; + col.alpha = 255; return col; } /////////////////////////////////////////////////////////////////////////////