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
This commit is contained in:
Michael R Sweet 2002-07-01 20:14:08 +00:00
parent 2d30a9e6fa
commit 526e94341d
9 changed files with 47 additions and 23 deletions

View File

@ -1,5 +1,9 @@
CHANGES IN FLTK 1.1.0
- Resource leak fixes under WIN32 from Ori Berger.
- Now register a WIN32 message for thread messages.
- Fl_Window didn't initialize the min and max window
size fields.
- The JPEG and PNG image classes have been moved to the
fltk_images library, a la FLTK 2.0. You can register
all image file formats provided in fltk_images using

View File

@ -1,5 +1,5 @@
//
// "$Id: win32.H,v 1.15.2.3.2.7 2002/06/07 15:06:31 easysw Exp $"
// "$Id: win32.H,v 1.15.2.3.2.8 2002/07/01 20:14:08 easysw Exp $"
//
// WIN32 header file for the Fast Light Tool Kit (FLTK).
//
@ -87,6 +87,7 @@ public:
static FL_EXPORT Fl_X* make(Fl_Window*);
};
extern FL_EXPORT HCURSOR fl_default_cursor;
extern FL_EXPORT UINT fl_wake_msg;
inline Window fl_xid(const Fl_Window*w) {return Fl_X::i(w)->xid;}
FL_EXPORT Fl_Window* fl_find(Window xid);
extern FL_EXPORT char fl_override_redirect; // hack into Fl_Window::make_xid()
@ -134,5 +135,5 @@ extern FL_EXPORT void fl_delete_bitmask(Fl_Bitmask bm);
extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b);
//
// End of "$Id: win32.H,v 1.15.2.3.2.7 2002/06/07 15:06:31 easysw Exp $".
// End of "$Id: win32.H,v 1.15.2.3.2.8 2002/07/01 20:14:08 easysw Exp $".
//

View File

@ -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 $".
//

View File

@ -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 $".
//

View File

@ -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 $".
//

View File

@ -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 $".
//

View File

@ -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 $".
*/

View File

@ -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 $".
//

View File

@ -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 $".
//