diff options
-rw-r--r-- | gtk/PlatGTK.cxx | 80 | ||||
-rw-r--r-- | gtk/ScintillaGTK.cxx | 9 | ||||
-rw-r--r-- | include/ScintillaWidget.h | 3 |
3 files changed, 54 insertions, 38 deletions
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index c30d877f2..8d61adde7 100644 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -38,57 +38,55 @@ #pragma warning(disable: 4505) #endif -typedef struct _logfont { - int size; - bool bold; - bool italic; - int characterSet; - char faceName[300]; -} LOGFONT; +struct LOGFONT { + int size; + bool bold; + bool italic; + int characterSet; + char faceName[300]; +}; #if USE_LOCK -GMutex *fontMutex = NULL; +static GMutex *fontMutex = NULL; #endif -void initializeGLIBThreads() { +static void InitializeGLIBThreads() { #if USE_LOCK - if (!g_thread_supported()) g_thread_init(NULL); + if (!g_thread_supported()) { + g_thread_init(NULL); + } #endif } -void fontMutexAllocate(void) { +static void FontMutexAllocate() { #if USE_LOCK - if (!fontMutex) { - initializeGLIBThreads(); - fontMutex = g_mutex_new(); - } + if (!fontMutex) { + InitializeGLIBThreads(); + fontMutex = g_mutex_new(); + } #endif } -void fontMutexFree(void) { +static void FontMutexFree() { #if USE_LOCK - if (fontMutex) { - g_mutex_free(fontMutex); - } + if (fontMutex) { + g_mutex_free(fontMutex); + fontMutex = NULL; + } #endif } -void fontMutexLock(void) { +static void FontMutexLock() { #if USE_LOCK - if (!fontMutex) { - /* this is indeed lame, but can be changed later to be put into - some kind of scintilla startup function */ - fontMutexAllocate(); - } - g_mutex_lock(fontMutex); + g_mutex_lock(fontMutex); #endif } -void fontMutexUnlock(void) { +static void FontMutexUnlock() { #if USE_LOCK - if (fontMutex) { - g_mutex_unlock(fontMutex); - } + if (fontMutex) { + g_mutex_unlock(fontMutex); + } #endif } @@ -234,7 +232,7 @@ static const char *CharacterSetName(int characterSet) { } } -void GenerateFontSpecStrings(const char *fontName, int characterSet, +static void GenerateFontSpecStrings(const char *fontName, int characterSet, char *foundary, int foundary_len, char *faceName, int faceName_len, char *charset, int charset_len) { @@ -279,7 +277,7 @@ void GenerateFontSpecStrings(const char *fontName, int characterSet, } } -void SetLogFont(LOGFONT &lf, const char *faceName, int characterSet, int size, bool bold, bool italic) { +static void SetLogFont(LOGFONT &lf, const char *faceName, int characterSet, int size, bool bold, bool italic) { memset(&lf, 0, sizeof(lf)); lf.size = size; lf.bold = bold; @@ -293,7 +291,7 @@ void SetLogFont(LOGFONT &lf, const char *faceName, int characterSet, int size, b * If one font is the same as another, its hash will be the same, but if the hash is the * same then they may still be different. */ -int HashFont(const char *faceName, int characterSet, int size, bool bold, bool italic) { +static int HashFont(const char *faceName, int characterSet, int size, bool bold, bool italic) { return size ^ (characterSet << 10) ^ @@ -346,7 +344,7 @@ void FontCached::Release() { FontID FontCached::FindOrCreate(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_) { FontID ret = 0; - fontMutexLock(); + FontMutexLock(); int hashFind = HashFont(faceName_, characterSet_, size_, bold_, italic_); for (FontCached *cur=first; cur; cur=cur->next) { if ((cur->hash == hashFind) && @@ -363,12 +361,12 @@ FontID FontCached::FindOrCreate(const char *faceName_, int characterSet_, int si ret = fc->id; } } - fontMutexUnlock(); + FontMutexUnlock(); return ret; } void FontCached::ReleaseId(FontID id_) { - fontMutexLock(); + FontMutexLock(); FontCached **pcur=&first; for (FontCached *cur=first; cur; cur=cur->next) { if (cur->id == id_) { @@ -383,7 +381,7 @@ void FontCached::ReleaseId(FontID id_) { } pcur=&cur->next; } - fontMutexUnlock(); + FontMutexUnlock(); } FontID FontCached::CreateNewFont(const char *fontName, int characterSet, @@ -1475,3 +1473,11 @@ int Platform::Clamp(int val, int minVal, int maxVal) { val = minVal; return val; } + +void Platform_Initialise() { + FontMutexAllocate(); +} + +void Platform_Finalise() { + FontMutexFree(); +} diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index 349a98292..3c87be91c 100644 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -1615,10 +1615,14 @@ sptr_t scintilla_send_message(ScintillaObject *sci, unsigned int iMessage, uptr_ static void scintilla_class_init (ScintillaClass *klass); static void scintilla_init (ScintillaObject *sci); +extern void Platform_Initialise(); +extern void Platform_Finalise(); + guint scintilla_get_type() { static guint scintilla_type = 0; if (!scintilla_type) { + Platform_Initialise(); static GtkTypeInfo scintilla_info = { "Scintilla", sizeof (ScintillaObject), @@ -1731,3 +1735,8 @@ void scintilla_set_id(ScintillaObject *sci, int id) { ScintillaGTK *psci = reinterpret_cast<ScintillaGTK *>(sci->pscin); psci->ctrlID = id; } + +void scintilla_release_resources(void) { + Platform_Finalise(); +} + diff --git a/include/ScintillaWidget.h b/include/ScintillaWidget.h index 203f35733..765fd8594 100644 --- a/include/ScintillaWidget.h +++ b/include/ScintillaWidget.h @@ -37,7 +37,8 @@ struct _ScintillaClass { guint scintilla_get_type (void); GtkWidget* scintilla_new (void); void scintilla_set_id (ScintillaObject *sci,int id); -sptr_t scintilla_send_message (ScintillaObject *sci,unsigned int iMessage, uptr_t wParam, sptr_t lParam); +sptr_t scintilla_send_message (ScintillaObject *sci,unsigned int iMessage, uptr_t wParam, sptr_t lParam); +void scintilla_release_resources(void); #if GTK_MAJOR_VERSION < 2 #define SCINTILLA_NOTIFY "notify" |