mirror of
https://github.com/fltk/fltk.git
synced 2026-05-20 22:36:19 +08:00
Fixed unbalanced Windows OleInitialize/OleUnitialize calls
when loading/unloading the FLTK dll (STR #2417) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7706 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
CHANGES IN FLTK 1.3.0
|
||||
|
||||
- Fixed unbalanced Windows OleInitialize/OleUnitialize calls
|
||||
when loading/unloading the FLTK dll (STR #2417)
|
||||
- Fixed X11/XDBE double buffering (STR #2152, #2197)
|
||||
- Added new label and image alignments (STR #2269)
|
||||
- Added documentation for event delivery (STR #1983)
|
||||
|
||||
+23
-1
@@ -484,13 +484,35 @@ int Fl::run() {
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
// Function to initialize COM/OLE for usage. This must be done only once.
|
||||
// We define a flag to register whether we called it:
|
||||
static char oleInitialized = 0;
|
||||
|
||||
// This calls the Windows function OleInitialize() exactly once.
|
||||
void fl_OleInitialize() {
|
||||
if (!oleInitialized) {
|
||||
OleInitialize(0L);
|
||||
oleInitialized = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// This calls the Windows function OleUninitialize() only, if
|
||||
// OleInitialize has been called before.
|
||||
void fl_OleUninitialize() {
|
||||
if (oleInitialized) {
|
||||
OleUninitialize();
|
||||
oleInitialized = 0;
|
||||
}
|
||||
}
|
||||
|
||||
class Fl_Win32_At_Exit {
|
||||
public:
|
||||
Fl_Win32_At_Exit() { }
|
||||
~Fl_Win32_At_Exit() {
|
||||
fl_free_fonts(); // do some WIN32 cleanup
|
||||
fl_cleanup_pens();
|
||||
OleUninitialize();
|
||||
fl_OleUninitialize();
|
||||
fl_brush_action(1);
|
||||
fl_cleanup_dc_list();
|
||||
}
|
||||
|
||||
@@ -47,6 +47,8 @@ char *wchartoutf8(LPCWSTR in); //MG
|
||||
#define RBRACKET_CHR ']'
|
||||
#define MAXFILTERS 80
|
||||
|
||||
void fl_OleInitialize(); // in Fl.cxx (Windows only)
|
||||
|
||||
// STATIC: PRINT WINDOWS 'DOUBLE NULL' STRING (DEBUG)
|
||||
static void dnullprint(char *wp) {
|
||||
if ( ! wp ) return;
|
||||
@@ -464,7 +466,8 @@ int CALLBACK Fl_Native_File_Chooser::Dir_CB(HWND win, UINT msg, LPARAM param, LP
|
||||
|
||||
// SHOW DIRECTORY BROWSER
|
||||
int Fl_Native_File_Chooser::showdir() {
|
||||
OleInitialize(NULL); // init needed by BIF_USENEWUI
|
||||
// initialize OLE only once
|
||||
fl_OleInitialize(); // init needed by BIF_USENEWUI
|
||||
ClearBINF();
|
||||
clear_pathnames();
|
||||
// PARENT WINDOW
|
||||
|
||||
+2
-6
@@ -1554,14 +1554,10 @@ Fl_X* Fl_X::make(Fl_Window* w) {
|
||||
// Drag-n-drop requires GCC 3.x or a non-GNU compiler...
|
||||
#if !defined(__GNUC__) || __GNUC__ >= 3
|
||||
// Register all windows for potential drag'n'drop operations
|
||||
static char oleInitialized = 0;
|
||||
if (!oleInitialized) { OleInitialize(0L); oleInitialized=1; }
|
||||
|
||||
fl_OleInitialize();
|
||||
RegisterDragDrop(x->xid, flIDropTarget);
|
||||
|
||||
if (!fl_aimm) {
|
||||
static char been_here = 0;
|
||||
if (!been_here && !oleInitialized) CoInitialize(NULL);
|
||||
been_here = 1;
|
||||
CoCreateInstance(CLSID_CActiveIMM, NULL, CLSCTX_INPROC_SERVER,
|
||||
IID_IActiveIMMApp, (void**) &fl_aimm);
|
||||
if (fl_aimm) {
|
||||
|
||||
Reference in New Issue
Block a user