Bug 56374 - kworldclock applet changes the display time of clock applet.
Summary: kworldclock applet changes the display time of clock applet.
Status: RESOLVED FIXED
Alias: None
Product: kworldclock
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Matthias Hoelzer-Kluepfel
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-03-25 13:31 UTC by Mitsuru KANDA
Modified: 2004-02-17 23:14 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mitsuru KANDA 2003-03-25 13:31:36 UTC
Version:           
Comment 1 Maksim Orlovich 2003-06-15 02:21:05 UTC
Can't reproduce, nor can see how it could happen. Could you please describe 
your panel setup in a lot of detail? (Screenshots are good, too) 
 
Comment 2 jsvrp.gw 2003-09-12 20:46:19 UTC
I can confirm this. Using KDE 3.1.3. I have the clock applet in the bottom right
and the worldclock applet in the center of the screen in a small autohide-applet.

When I move my mousepointer over the small worldclock applet, my clock changes
it's  time to the first one the worldclock applet shows me. 

e.g. Moving the mousepointer to Moskow, changed my clock from 20:44 to 22:44
(from Amsterdam-time to Moskow-time. When I go back to the worldclock applet, I
can't reproduce this, until I change the clock aplet back to the right timezone.
Comment 3 jsvrp.gw 2003-09-12 21:04:03 UTC
I just noticed that, when I remove the worldclockapplet and add it again, the
problem seems to be resolved. 
Comment 4 jsvrp.gw 2003-09-12 22:15:47 UTC
I also noticed that after a relogin, the problem reappeared. :-(
Comment 5 Clayton L. Workman 2003-11-09 14:59:18 UTC
I can reconfirm this.  It happens to me about 80% of the time (it's not 100% reproducible.)  

When I move the cursor in the kworldclock applet, the KDE clock will change time to the time of the city over which I placed the cursor in the kworldclock applet.  One way I can get the KDE clock back to normal is to right click on it, configure clock, apply and close.  Then the KDE clock time goes back to normal.  (Until I put my cursor in the kworldclock applet again - Ha, it just now did it!)

This is a very annoying bug.
Comment 6 Clayton L. Workman 2003-11-09 15:00:14 UTC
I should say, I'm using SUSE 9.0.
Comment 7 Ben Burton 2004-02-17 04:30:36 UTC
Hi.  I can also reproduce this bug (and indeed it's quite disturbing
since you can no longer trust the kicker clock).

It only happens to me when kworldclock is in the kicker panel, not
running as a standalone application.

Ah, and I think I've found the fault.  If $TZ is not initially present
in the environment, kworldclock does not *unset* it after it's looked up
the time in a different timezone.

i.e., it calls:

  initial_TZ = getenv("TZ");    // initial_TZ == 0 since $TZ was not set
  setenv("TZ", new_timezone);
  time();
  if (initialTZ != 0)
    setenv("TZ", initial_TZ);   // FAILS because initial_TZ == 0
  tzset();                      // Still stuck in new_timezone

This happens in both MapWidget::cityTime() and ZoneClock::updateTime().
Presumably the

  if (initialTZ != 0) setenv(...)

needs to be followed by an

  else unsetenv("TZ");

in each place.  I'll test this out tonight and see if it fixes the
problem.

Ben.

Comment 8 Ben Burton 2004-02-17 05:33:43 UTC
Yep, it fixes it for me.  The patch is below (patch is against 3_1_BRANCH
but should work fine with 3_2_BRANCH and HEAD also).

Ben.


--- kworldwatch/mapwidget.cpp	2 Mar 2003 21:50:43 -0000	1.16.2.2
+++ kworldwatch/mapwidget.cpp	17 Feb 2004 04:27:27 -0000
@@ -323,7 +323,10 @@ QString MapWidget::cityTime(QString city
   dt.setTime_t(t);
   result.append(QString("%1, %2").arg(KGlobal::locale()->formatTime(dt.time(), true)).arg(KGlobal::locale()->formatDate(dt.date(), true)));
 
-  if (initial_TZ != 0) setenv("TZ", initial_TZ, 1);
+  if (initial_TZ != 0)
+    setenv("TZ", initial_TZ, 1);
+  else
+    unsetenv("TZ");
   tzset(); 
   return result;
 }
--- kworldwatch/zoneclock.cpp	4 Feb 2003 14:53:18 -0000	1.6.2.1
+++ kworldwatch/zoneclock.cpp	17 Feb 2004 04:27:27 -0000
@@ -131,7 +131,10 @@ void ZoneClock::updateTime()
   dt.setTime_t(t);
   _timeLabel->setText(QString("%1, %2").arg(KGlobal::locale()->formatTime(dt.time(), true)).arg(KGlobal::locale()->formatDate(dt.date(), true)));
  
-  if (initial_TZ != 0) setenv("TZ", initial_TZ, 1);
+  if (initial_TZ != 0)
+    setenv("TZ", initial_TZ, 1);
+  else
+    unsetenv("TZ");
   tzset();
 }
 

Comment 9 Ben Burton 2004-02-17 23:14:01 UTC
CVS commit by benb: 

Unset $TZ where appropriate so kworldclock doesn't mess with the kicker clock.

CCMAIL: 56374-done@bugs.kde.org


  M +4 -1      mapwidget.cpp   1.25
  M +4 -1      zoneclock.cpp   1.10


--- kdetoys/kworldwatch/mapwidget.cpp  #1.24:1.25
@@ -359,5 +359,8 @@ QString MapWidget::cityTime(QString city
   result.append(QString("%1, %2").arg(KGlobal::locale()->formatTime(dt.time(), true)).arg(KGlobal::locale()->formatDate(dt.date(), true)));
 
-  if (initial_TZ != 0) setenv("TZ", initial_TZ, 1);
+  if (initial_TZ != 0)
+    setenv("TZ", initial_TZ, 1);
+  else
+    unsetenv("TZ");
   tzset(); 
   return result;

--- kdetoys/kworldwatch/zoneclock.cpp  #1.9:1.10
@@ -155,5 +155,8 @@ void ZoneClock::updateTime()
   _timeLabel->setText(QString("%1, %2").arg(KGlobal::locale()->formatTime(dt.time(), true)).arg(KGlobal::locale()->formatDate(dt.date(), true)));
 
-  if (initial_TZ != 0) setenv("TZ", initial_TZ, 1);
+  if (initial_TZ != 0)
+    setenv("TZ", initial_TZ, 1);
+  else
+    unsetenv("TZ");
   tzset();
 }