summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2002-07-01 20:14:08 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2002-07-01 20:14:08 +0000
commit526e94341d0a03bd99bbdbdeff7e446e437478c4 (patch)
tree1bb3b699e13ee2f94eb256f32712b41860906659 /src
parent2d30a9e6fa5f7a328c942fe7b0b68908339c9076 (diff)
Some patches from Ori Berger to plug some resource leaks and use a
different WIN32 message for threading under Windows. (didn't include the cleanup or release changes) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2336 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Preferences.cxx6
-rw-r--r--src/Fl_Window.cxx5
-rw-r--r--src/Fl_lock.cxx7
-rw-r--r--src/Fl_win32.cxx14
-rw-r--r--src/fl_call_main.c16
-rw-r--r--src/fl_color_win32.cxx7
-rw-r--r--src/fl_set_font.cxx6
7 files changed, 40 insertions, 21 deletions
diff --git a/src/Fl_Preferences.cxx b/src/Fl_Preferences.cxx
index 8b693ce6f..e922d948d 100644
--- a/src/Fl_Preferences.cxx
+++ b/src/Fl_Preferences.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Preferences.cxx,v 1.1.2.16 2002/05/31 19:27:56 easysw Exp $"
+// "$Id: Fl_Preferences.cxx,v 1.1.2.17 2002/07/01 20:14:08 easysw Exp $"
//
// Preferences methods for the Fast Light Tool Kit (FLTK).
//
@@ -595,6 +595,7 @@ Fl_Preferences::RootNode::RootNode( Fl_Preferences *prefs, Root root, const char
err = RegQueryValueEx( key, "Common AppData", 0L, &type, (BYTE*)filename, &nn );
if ( ( err != ERROR_SUCCESS ) && ( type == REG_SZ ) )
filename[0] = 0;
+ RegCloseKey(key);
}
break;
case USER:
@@ -604,6 +605,7 @@ Fl_Preferences::RootNode::RootNode( Fl_Preferences *prefs, Root root, const char
err = RegQueryValueEx( key, "AppData", 0L, &type, (BYTE*)filename, &nn );
if ( ( err != ERROR_SUCCESS ) && ( type == REG_SZ ) )
filename[0] = 0;
+ RegCloseKey(key);
}
break;
}
@@ -1050,5 +1052,5 @@ char Fl_Preferences::Node::remove()
//
-// End of "$Id: Fl_Preferences.cxx,v 1.1.2.16 2002/05/31 19:27:56 easysw Exp $".
+// End of "$Id: Fl_Preferences.cxx,v 1.1.2.17 2002/07/01 20:14:08 easysw Exp $".
//
diff --git a/src/Fl_Window.cxx b/src/Fl_Window.cxx
index 7326a53e8..8e71e86c1 100644
--- a/src/Fl_Window.cxx
+++ b/src/Fl_Window.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Window.cxx,v 1.6.2.3.2.5 2002/05/04 12:49:31 easysw Exp $"
+// "$Id: Fl_Window.cxx,v 1.6.2.3.2.6 2002/07/01 20:14:08 easysw Exp $"
//
// Window widget class for the Fast Light Tool Kit (FLTK).
//
@@ -47,6 +47,7 @@ void Fl_Window::_Fl_Window() {
iconlabel_ = 0;
resizable(0);
size_range_set = 0;
+ minw = maxw = minh = maxh = 0;
callback((Fl_Callback*)default_callback);
}
@@ -113,5 +114,5 @@ void Fl_Window::default_callback(Fl_Window* window, void* v) {
}
//
-// End of "$Id: Fl_Window.cxx,v 1.6.2.3.2.5 2002/05/04 12:49:31 easysw Exp $".
+// End of "$Id: Fl_Window.cxx,v 1.6.2.3.2.6 2002/07/01 20:14:08 easysw Exp $".
//
diff --git a/src/Fl_lock.cxx b/src/Fl_lock.cxx
index 213dfb3a2..aae61b022 100644
--- a/src/Fl_lock.cxx
+++ b/src/Fl_lock.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_lock.cxx,v 1.13.2.2 2002/01/01 15:11:31 easysw Exp $"
+// "$Id: Fl_lock.cxx,v 1.13.2.3 2002/07/01 20:14:08 easysw Exp $"
//
// Multi-threading support code for the Fast Light Tool Kit (FLTK).
//
@@ -58,6 +58,7 @@
#ifdef WIN32
# include <windows.h>
# include <process.h>
+# include <FL/x.H>
// These pointers are in Fl_win32.cxx:
extern void (*fl_lock_function)();
@@ -117,7 +118,7 @@ void Fl::unlock() {
//
void Fl::awake(void* msg) {
- PostThreadMessage( main_thread, WM_USER, (WPARAM)msg, 0);
+ PostThreadMessage( main_thread, fl_wake_msg, (WPARAM)msg, 0);
}
////////////////////////////////////////////////////////////////
@@ -199,5 +200,5 @@ void Fl::awake(void* msg) {
#endif
//
-// End of "$Id: Fl_lock.cxx,v 1.13.2.2 2002/01/01 15:11:31 easysw Exp $".
+// End of "$Id: Fl_lock.cxx,v 1.13.2.3 2002/07/01 20:14:08 easysw Exp $".
//
diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx
index 0266b9e01..7a0d777e6 100644
--- a/src/Fl_win32.cxx
+++ b/src/Fl_win32.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_win32.cxx,v 1.33.2.37.2.36 2002/06/07 16:37:48 easysw Exp $"
+// "$Id: Fl_win32.cxx,v 1.33.2.37.2.37 2002/07/01 20:14:08 easysw Exp $"
//
// WIN32-specific code for the Fast Light Tool Kit (FLTK).
//
@@ -285,7 +285,7 @@ int fl_wait(double time_to_wait) {
}
#endif
- if (fl_msg.message == WM_USER) // Used for awaking wait() from another thread
+ if (fl_msg.message == fl_wake_msg) // Used for awaking wait() from another thread
thread_message_ = (void*)fl_msg.wParam;
TranslateMessage(&fl_msg);
@@ -580,7 +580,6 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
break;
case WM_PAINT: {
-
Fl_X *i = Fl_X::i(window);
i->wait_for_expose = 0;
// We need to merge this damage into fltk's damage. I do this in
@@ -598,6 +597,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
// is deferred until Fl::flush() is called during idle. However Win32
// apparently is very unhappy if we don't obey it and draw right now.
// Very annoying!
+ fl_GetDC(hWnd); // Make sure we have a DC for this window...
fl_save_pen();
i->flush();
fl_restore_pen();
@@ -827,7 +827,7 @@ int Fl_X::fake_X_wm(const Fl_Window* w,int &X,int &Y, int &bt,int &bx, int &by)
int W, H, xoff, yoff, dx, dy;
int ret = bx = by = bt = 0;
if (w->border() && !w->parent()) {
- if (w->maxw != w->minw || w->maxh != w->minh) {
+ if (w->size_range_set && (w->maxw != w->minw || w->maxh != w->minh)) {
ret = 2;
bx = GetSystemMetrics(SM_CXSIZEFRAME);
by = GetSystemMetrics(SM_CYSIZEFRAME);
@@ -911,6 +911,7 @@ void fl_fix_focus(); // in Fl.cxx
char fl_show_iconic; // hack for Fl_Window::iconic()
// int fl_background_pixel = -1; // color to use for background
HCURSOR fl_default_cursor;
+UINT fl_wake_msg = 0;
int fl_disable_transient_for; // secret method of removing TRANSIENT_FOR
Fl_X* Fl_X::make(Fl_Window* w) {
@@ -919,6 +920,8 @@ Fl_X* Fl_X::make(Fl_Window* w) {
const char* class_name = /*w->xclass();
if (!class_name) class_name =*/ "FLTK"; // create a "FLTK" WNDCLASS
+ const char* message_name = "FLTK::ThreadWakeup";
+
WNDCLASSEX wc;
// Documentation states a device context consumes about 800 bytes
// of memory... so who cares? If 800 bytes per window is what it
@@ -939,6 +942,7 @@ Fl_X* Fl_X::make(Fl_Window* w) {
wc.lpszClassName = class_name;
wc.cbSize = sizeof(WNDCLASSEX);
RegisterClassEx(&wc);
+ if (!fl_wake_msg) fl_wake_msg = RegisterWindowMessage(message_name);
HWND parent;
DWORD style = WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
@@ -1175,5 +1179,5 @@ void Fl_Window::make_current() {
}
//
-// End of "$Id: Fl_win32.cxx,v 1.33.2.37.2.36 2002/06/07 16:37:48 easysw Exp $".
+// End of "$Id: Fl_win32.cxx,v 1.33.2.37.2.37 2002/07/01 20:14:08 easysw Exp $".
//
diff --git a/src/fl_call_main.c b/src/fl_call_main.c
index 4aa26c026..1921d98da 100644
--- a/src/fl_call_main.c
+++ b/src/fl_call_main.c
@@ -1,5 +1,5 @@
/*
- * "$Id: fl_call_main.c,v 1.1.2.11.2.2 2002/06/29 00:10:04 matthiaswm Exp $"
+ * "$Id: fl_call_main.c,v 1.1.2.11.2.3 2002/07/01 20:14:08 easysw Exp $"
*
* Copyright 1998-2002 by Bill Spitzak and others.
*
@@ -63,6 +63,8 @@ extern int main(int, char *[]);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow) {
+ int rc;
+
#ifdef _DEBUG
/*
* If we are using compiling in debug mode, open a console window so
@@ -81,7 +83,15 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
#endif /* _DEBUG */
/* Run the standard main entry point function... */
- return main(__argc, __argv);
+ rc = main(__argc, __argv);
+
+#ifdef _DEBUG
+ fclose(stdin);
+ fclose(stdout);
+ fclose(stderr);
+#endif /* _DEBUG */
+
+ return rc;
}
#else
@@ -90,6 +100,6 @@ static void dummy(void) {dummy();}
#endif
/*
- * End of "$Id: fl_call_main.c,v 1.1.2.11.2.2 2002/06/29 00:10:04 matthiaswm Exp $".
+ * End of "$Id: fl_call_main.c,v 1.1.2.11.2.3 2002/07/01 20:14:08 easysw Exp $".
*/
diff --git a/src/fl_color_win32.cxx b/src/fl_color_win32.cxx
index 1c2d328c7..93218ef05 100644
--- a/src/fl_color_win32.cxx
+++ b/src/fl_color_win32.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_color_win32.cxx,v 1.14.2.3.2.5 2002/06/07 16:37:48 easysw Exp $"
+// "$Id: fl_color_win32.cxx,v 1.14.2.3.2.6 2002/07/01 20:14:08 easysw Exp $"
//
// WIN32 color functions for the Fast Light Tool Kit (FLTK).
//
@@ -57,7 +57,8 @@ void fl_save_pen(void) {
}
void fl_restore_pen(void) {
- SelectObject(fl_gc, savepen);
+ if (savepen) SelectObject(fl_gc, savepen);
+ savepen = 0;
}
static void clear_xmap(Fl_XMap& xmap) {
@@ -222,5 +223,5 @@ fl_select_palette(void)
#endif
//
-// End of "$Id: fl_color_win32.cxx,v 1.14.2.3.2.5 2002/06/07 16:37:48 easysw Exp $".
+// End of "$Id: fl_color_win32.cxx,v 1.14.2.3.2.6 2002/07/01 20:14:08 easysw Exp $".
//
diff --git a/src/fl_set_font.cxx b/src/fl_set_font.cxx
index 2bd3b469f..d3c10a51c 100644
--- a/src/fl_set_font.cxx
+++ b/src/fl_set_font.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_set_font.cxx,v 1.5.2.3.2.6 2002/05/25 13:38:25 easysw Exp $"
+// "$Id: fl_set_font.cxx,v 1.5.2.3.2.7 2002/07/01 20:14:08 easysw Exp $"
//
// Font utilities for the Fast Light Tool Kit (FLTK).
//
@@ -35,7 +35,7 @@
static int table_size;
void Fl::set_font(Fl_Font fnum, const char* name) {
- if (fnum >= table_size) {
+ while (fnum >= table_size) {
int i = table_size;
if (!i) { // don't realloc the built-in table
table_size = 2*FL_FREE_FONT;
@@ -74,5 +74,5 @@ void Fl::set_font(Fl_Font fnum, Fl_Font from) {
const char* Fl::get_font(Fl_Font fnum) {return fl_fonts[fnum].name;}
//
-// End of "$Id: fl_set_font.cxx,v 1.5.2.3.2.6 2002/05/25 13:38:25 easysw Exp $".
+// End of "$Id: fl_set_font.cxx,v 1.5.2.3.2.7 2002/07/01 20:14:08 easysw Exp $".
//