From 78e391fbb09dd311a00a6b17a1032520eace0cab Mon Sep 17 00:00:00 2001 From: cxl Date: Fri, 30 Jan 2009 12:17:59 +0000 Subject: [PATCH] SetIniFile with NULL forces reload, MSSQL schema files create primary keys, Updater fixed git-svn-id: svn://ultimatepp.org/upp/trunk@827 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/Util.cpp | 7 ++++--- uppsrc/Core/Util.h | 2 +- uppsrc/OleDB/OleDBSchema.h | 7 ++++++- uppsrc/Updater/Updater.cpp | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/uppsrc/Core/Util.cpp b/uppsrc/Core/Util.cpp index 65fa6c080..eba62c02c 100644 --- a/uppsrc/Core/Util.cpp +++ b/uppsrc/Core/Util.cpp @@ -362,16 +362,17 @@ VectorMap LoadIniFile(const char *filename) { } const char *sIniFile; +static bool s_ini_loaded; void SetIniFile(const char *name) { sIniFile = name; + s_ini_loaded = false; } String GetIniKey(const char *name) { - static bool loaded; static VectorMap key; - if(!loaded) { - loaded = true; + if(!s_ini_loaded) { + s_ini_loaded = true; key = LoadIniFile(sIniFile ? sIniFile : ~ConfigFile("q.ini")); #ifdef PLATFORM_WIN32 if(key.GetCount() == 0) diff --git a/uppsrc/Core/Util.h b/uppsrc/Core/Util.h index 8a024e855..3dea1439f 100644 --- a/uppsrc/Core/Util.h +++ b/uppsrc/Core/Util.h @@ -22,7 +22,7 @@ public: void SetAssertFailedHook(void (*h)(const char *)); -void SetIniFile(const char *name); +void SetIniFile(const char *name = NULL); String GetIniKey(const char *name); VectorMap LoadIniFile(const char *filename); diff --git a/uppsrc/OleDB/OleDBSchema.h b/uppsrc/OleDB/OleDBSchema.h index 8c57548e6..cbdfcebbf 100644 --- a/uppsrc/OleDB/OleDBSchema.h +++ b/uppsrc/OleDB/OleDBSchema.h @@ -31,7 +31,12 @@ #define LONGRAW(x) COLUMN("varbinary(max)", String, x, 0, 0) #define LONGRAW_(x) COLUMN_("varbinary(max)", String, x, 0, 0) -#define PRIMARY_KEY INLINE_ATTRIBUTE("primary key") +#define PRIMARY_KEY INLINE_ATTRIBUTE("primary key")\ + ATTRIBUTE("alter table @t add constraint PK_@x primary key "\ + "(@c)",\ + "alter table @t drop constraint PK_@x;")\ + ATTRIBUTE("create index PKX_@x on @t(@c);", \ + "drop index PKX_@x;") #define KEY INLINE_ATTRIBUTE("key") #define NOT_NULL INLINE_ATTRIBUTE("not null") #define IDENTITY INLINE_ATTRIBUTE("identity") diff --git a/uppsrc/Updater/Updater.cpp b/uppsrc/Updater/Updater.cpp index 3f0513389..541548c12 100644 --- a/uppsrc/Updater/Updater.cpp +++ b/uppsrc/Updater/Updater.cpp @@ -14,7 +14,7 @@ GUI_APP_MAIN String name = cmdline[0]; UpdateFile(name); String exec = GetExeDirFile(name); - for(i = 1; i < cmdline.GetCount(); i++) + for(int i = 1; i < cmdline.GetCount(); i++) if(cmdline[i].Find(' ') >= 0) exec << " \"" << cmdline[i] << "\""; else