27 #include <tqptrlist.h>
30 #include <kapplication.h>
31 #include <kaboutdata.h>
35 #include <kcharsets.h>
36 #include <kiconloader.h>
37 #include <kstandarddirs.h>
38 #include <kinstance.h>
39 #include "kstaticdeleter.h"
44 #define MYASSERT(x) if (!x) \
45 qFatal("Fatal error: you need to have a KInstance object before\n" \
46 "you do anything that requires it! Examples of this are config\n" \
47 "objects, standard directories or translations.");
52 static void kglobal_init();
58 return _instance->
dirs();
65 return _instance->
config();
96 KLocale::initInstance();
98 _instance->
aboutData()->translateInternalProgramName();
106 if( _charsets == 0 ) {
133 class KStringDict :
public TQDict<TQString>
136 KStringDict() : TQDict<TQString>(139) { }
149 _stringDict =
new KStringDict;
150 _stringDict->setAutoDelete(
true );
153 TQString *result = _stringDict->find(str);
156 result =
new TQString(str);
157 _stringDict->insert(str, result);
162 class KStaticDeleterList:
public TQPtrList<KStaticDeleterBase>
165 KStaticDeleterList() { }
171 if (!_staticDeleters)
173 if (_staticDeleters->find(obj) == -1)
174 _staticDeleters->append(obj);
181 _staticDeleters->removeRef(obj);
187 if (!KGlobal::_staticDeleters)
190 for(;_staticDeleters->count();)
192 _staticDeleters->take(0)->destructObject();
195 delete KGlobal::_staticDeleters;
196 KGlobal::_staticDeleters = 0;
201 KStringDict *KGlobal::_stringDict = 0;
206 KStaticDeleterList *KGlobal::_staticDeleters = 0;
210 static void kglobal_freeAll();
211 BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID impLoad )
213 if (reason == DLL_PROCESS_DETACH)
218 __attribute__((destructor))
220 static void kglobal_freeAll()
222 delete KGlobal::_locale;
223 KGlobal::_locale = 0;
224 delete KGlobal::_charsets;
225 KGlobal::_charsets = 0;
226 delete KGlobal::_stringDict;
227 KGlobal::_stringDict = 0;
233 static void kglobal_init()
235 if (KGlobal::_staticDeleters)
238 KGlobal::_staticDeleters =
new KStaticDeleterList;
241 int kasciistricmp(
const char *str1,
const char *str2 )
243 const unsigned char *s1 = (
const unsigned char *)str1;
244 const unsigned char *s2 = (
const unsigned char *)str2;
246 unsigned char c1, c2;
249 return s1 ? 1 : (s2 ? -1 : 0);
251 return *s1 ? 1 : (*s2 ? -1 : 0);
252 for (;*s1; ++s1, ++s2) {
254 if (c1 >=
'A' && c1 <=
'Z')
256 if (c2 >=
'A' && c2 <=
'Z')
262 return *s1 ? res : (*s2 ? -1 : 0);