[Tkabber-dev] r1640 - trunk/tkabber

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Thu Feb 5 23:57:57 MSK 2009


Author: sergei
Date: 2009-02-05 23:57:55 +0300 (Thu, 05 Feb 2009)
New Revision: 1640

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/custom.tcl
Log:
	* custom.tcl: Store customization variables to a temporary file and
	  then move it to custom.tcl to prevent custom.tcl accidental
	  corruption.


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2009-02-04 18:33:34 UTC (rev 1639)
+++ trunk/tkabber/ChangeLog	2009-02-05 20:57:55 UTC (rev 1640)
@@ -1,3 +1,9 @@
+2009-02-05  Sergei Golovan  <sgolovan at nes.ru>
+
+	* custom.tcl: Store customization variables to a temporary file and
+	  then move it to custom.tcl to prevent custom.tcl accidental
+	  corruption.
+
 2009-02-04  Sergei Golovan  <sgolovan at nes.ru>
 
 	* plugins/general/geometry.tcl: Added new plugin which saves main

Modified: trunk/tkabber/custom.tcl
===================================================================
--- trunk/tkabber/custom.tcl	2009-02-04 18:33:34 UTC (rev 1639)
+++ trunk/tkabber/custom.tcl	2009-02-05 20:57:55 UTC (rev 1640)
@@ -6,6 +6,7 @@
 namespace eval custom {
     # Filename for saving options
     set options(customfile) [file join $::configdir custom.tcl]
+    set options(customfile~) [file join $::configdir custom.tcl~]
 
     # -1: stored values haven't been restored yet (only config changes vars)
     # 0: stored values are being restored now
@@ -715,7 +716,7 @@
     variable saved
     variable options
 
-    set fd [open $options(customfile) w]
+    set fd [open $options(customfile~) w]
     fconfigure $fd -encoding utf-8
 
     foreach varname [array names saved] {
@@ -732,7 +733,8 @@
     }
 
     close $fd
-    catch {file attributes [file join $::configdir custom.tcl] -permissions 00600}
+    catch {file attributes $options(customfile~) -permissions 00600}
+    file rename -force $options(customfile~) $options(customfile)
 }
 
 proc custom::store_vars {args} {



More information about the Tkabber-dev mailing list