diff options
| author | George Hazan <george.hazan@gmail.com> | 2013-03-18 08:18:13 +0000 | 
|---|---|---|
| committer | George Hazan <george.hazan@gmail.com> | 2013-03-18 08:18:13 +0000 | 
| commit | e63908912809cd6aeeeb2d068da562c227cbd3a9 (patch) | |
| tree | db3d95b3fc111d31d1a4dc23d8e094990105014f | |
| parent | d90a9d04b3b6e2beaa31b311fd38b886a46bab72 (diff) | |
clutch for pascal plugins not to eat memory on thread creation
git-svn-id: http://svn.miranda-ng.org/main/trunk@4085 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
| -rw-r--r-- | plugins/Actman/actman.dpr | 8 | ||||
| -rw-r--r-- | plugins/HistoryPlusPlus/historypp.dpr | 1 | ||||
| -rw-r--r-- | plugins/ImportTXT/importtxt.dpr | 7 | ||||
| -rw-r--r-- | plugins/QuickSearch/quicksearch.dpr | 4 | ||||
| -rw-r--r-- | plugins/ShlExt/shlcom.pas | 39 | ||||
| -rw-r--r-- | plugins/ShlExt/shlext.dpr | 9 | ||||
| -rw-r--r-- | plugins/Watrack/watrack.dpr | 4 | ||||
| -rw-r--r-- | plugins/mRadio/mradio.dpr | 4 | 
8 files changed, 31 insertions, 45 deletions
diff --git a/plugins/Actman/actman.dpr b/plugins/Actman/actman.dpr index caf0319c6a..5428411585 100644 --- a/plugins/Actman/actman.dpr +++ b/plugins/Actman/actman.dpr @@ -136,7 +136,7 @@ begin    LoadGroups;
    RegisterIcons;
 -  
 +
    opthook      :=HookEvent(ME_OPT_INITIALISE ,@OnOptInitialise);
    hHookShutdown:=HookEvent(ME_SYSTEM_SHUTDOWN{ME_SYSTEM_OKTOEXIT},@PreShutdown);
    NotifyEventHooks(hHookChanged,twparam(ACTM_LOADED),0);
 @@ -183,7 +183,9 @@ begin  end;
  exports
 -  Load, Unload,
 -  MirandaPluginInfoEx;
 +  Load, Unload, MirandaPluginInfoEx;
 +
 +initialization
 +  DisableThreadLibraryCalls(hInstance);
  end.
 diff --git a/plugins/HistoryPlusPlus/historypp.dpr b/plugins/HistoryPlusPlus/historypp.dpr index 876722eca7..45573f1314 100644 --- a/plugins/HistoryPlusPlus/historypp.dpr +++ b/plugins/HistoryPlusPlus/historypp.dpr @@ -573,6 +573,7 @@ exports    Unload;
  begin
 +  DisableThreadLibraryCalls(hInstance);
    // decreasing ref count to oleaut32.dll as said
    // in plugins doc
 diff --git a/plugins/ImportTXT/importtxt.dpr b/plugins/ImportTXT/importtxt.dpr index 43d4b560e0..68f1081321 100644 --- a/plugins/ImportTXT/importtxt.dpr +++ b/plugins/ImportTXT/importtxt.dpr @@ -151,11 +151,10 @@ begin    Result := 0;
  end;
 -
  exports
 +  Load, Unload, MirandaPluginInfoEx;
 -  Load, Unload,
 -  MirandaPluginInfoEx;
 +initialization
 +  DisableThreadLibraryCalls(hInstance);
 -begin
  end.
 diff --git a/plugins/QuickSearch/quicksearch.dpr b/plugins/QuickSearch/quicksearch.dpr index 80901724d6..856f3376d3 100644 --- a/plugins/QuickSearch/quicksearch.dpr +++ b/plugins/QuickSearch/quicksearch.dpr @@ -240,5 +240,7 @@ exports    Load, Unload,
    MirandaPluginInfoEx;
 -begin
 +initialization
 +  DisableThreadLibraryCalls(hInstance);
 +
  end.
 diff --git a/plugins/ShlExt/shlcom.pas b/plugins/ShlExt/shlcom.pas index fb9b4fa780..8aeb14c62b 100644 --- a/plugins/ShlExt/shlcom.pas +++ b/plugins/ShlExt/shlcom.pas @@ -1737,7 +1737,7 @@ begin    SetEvent(p^.hEvent);
  end;
 -function IssueTransferThread(pipch: PHeaderIPC): Cardinal; stdcall;
 +procedure IssueTransferThread(pipch: PHeaderIPC); cdecl;
  var
    szBuf: array [0 .. MAX_PATH] of Char;
    pct: PSlotIPC;
 @@ -1747,8 +1747,6 @@ var    p: Pointer;
    hMainThread: THandle;
  begin
 -  result:=0;
 -  Thread_Push(0,nil);
    hMainThread := THandle(pipch^.Param);
    GetCurrentDirectory(sizeof(szBuf), szBuf);
    args.count := 0;
 @@ -1795,8 +1793,6 @@ begin    SetCurrentDirectory(szBuf);
    FreeMem(pipch);
    CloseHandle(hMainThread);
 -  Thread_Pop();
 -  ExitThread(0);
  end;
  type
 @@ -2071,7 +2067,7 @@ begin  end;
  // worker thread to clear MRU, called by the IPC bridge
 -function ClearMRUThread(notused: Pointer): Cardinal; stdcall;
 +procedure ClearMRUThread(notused: Pointer); cdecl;
  {$DEFINE SHL_IDC}
  {$DEFINE SHL_KEYS}
  {$INCLUDE shlc.inc}
 @@ -2080,9 +2076,6 @@ function ClearMRUThread(notused: Pointer): Cardinal; stdcall;  var
    hContact: THandle;
  begin
 -  result:=0;
 -  Thread_Push(0,nil);
 -
    begin
      hContact := CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
      while hContact <> 0 do
 @@ -2094,8 +2087,6 @@ begin        hContact := CallService(MS_DB_CONTACT_FINDNEXT, hContact, 0);
      end;
    end;
 -  Thread_Pop();
 -  ExitThread(0);
  end;
  // this function is called from an APC into the main thread
 @@ -2141,13 +2132,13 @@ begin          ipcFixupAddresses(True, cloned);
          DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(),
            @cloned^.Param, THREAD_SET_CONTEXT, False, 0);
 -        CloseHandle(CreateThread(nil, 0, @IssueTransferThread, cloned, 0, tid));
 +        mir_forkThread(@IssueTransferThread, cloned);
          goto Reply;
        end;
        // the request was to clear the MRU entries, we have no return data
        if (bits^ and REQUEST_CLEARMRU) = REQUEST_CLEARMRU then
        begin
 -        CloseHandle(CreateThread(nil, 0, @ClearMRUThread, nil, 0, tid));
 +        mir_forkThread(@ClearMRUThread, nil);
          goto Reply;
        end;
        // the IPC header may have pointers that need to be translated
 @@ -2266,20 +2257,16 @@ begin    //
  end;
 -function ThreadServer(hMainThread: Pointer): Cardinal;
 -{$IFDEF FPC}
 -stdcall;
 -{$ENDIF}
 +procedure ThreadServer(hMainThread: Pointer); cdecl;
  var
    hEvent: THandle;
 +  retVal: Cardinal;
  begin
 -  result:=0;
 -  Thread_Push(0,nil);
    hEvent := CreateEvent(nil, False, False, PChar(CreateProcessUID(GetCurrentProcessId())));
    while True do
    begin
 -    Result := WaitForSingleObjectEx(hEvent, INFINITE, True);
 -    if Result = WAIT_OBJECT_0 then
 +    retVal := WaitForSingleObjectEx(hEvent, INFINITE, True);
 +    if retVal = WAIT_OBJECT_0 then
      begin
        QueueUserAPC(@ipcService, THandle(hMainThread), 0);
      end; // if
 @@ -2288,8 +2275,6 @@ begin    end; // while
    CloseHandle(hEvent);
    CloseHandle(THandle(hMainThread));
 -  Thread_Pop();
 -  ExitThread(0);
  end;
  procedure InvokeThreadServer;
 @@ -2306,13 +2291,7 @@ begin    DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), @hMainThread,
      THREAD_SET_CONTEXT, False, 0);
    if hMainThread <> 0 then
 -  begin
 -{$IFDEF FPC}
 -    CloseHandle(CreateThread(nil, 0, @ThreadServer, Pointer(hMainThread), 0, tid));
 -{$ELSE}
 -    CloseHandle(BeginThread(nil, 0, @ThreadServer, Pointer(hMainThread), 0, tid));
 -{$ENDIF}
 -  end; // if
 +    mir_forkThread(@ThreadServer, Pointer(hMainThread));
  end;
  { exported functions }
 diff --git a/plugins/ShlExt/shlext.dpr b/plugins/ShlExt/shlext.dpr index f8a9cb0420..32d1eab0c7 100644 --- a/plugins/ShlExt/shlext.dpr +++ b/plugins/ShlExt/shlext.dpr @@ -1,4 +1,4 @@ -{$IFDEF FPC} +{$IFDEF FPC}
  {$PACKRECORDS 4}
  {$MODE Delphi}
  {$ASMMODE intel}
 @@ -384,13 +384,12 @@ end;  {$R shldlgs.res}
  exports
 -
    MirandaPluginInfoEx, Load, Unload;
  exports
 -
    DllGetClassObject, DllCanUnloadNow, DllRegisterServer, DllUnregisterServer;
 -begin
 +initialization
 +  DisableThreadLibraryCalls(hInstance);
 -end. +end.
 diff --git a/plugins/Watrack/watrack.dpr b/plugins/Watrack/watrack.dpr index 7c48e5eb29..2a0929c2d1 100644 --- a/plugins/Watrack/watrack.dpr +++ b/plugins/Watrack/watrack.dpr @@ -713,5 +713,7 @@ exports    Load, Unload,
    MirandaPluginInfoEx;
 -begin
 +initialization
 +  DisableThreadLibraryCalls(hInstance);
 +
  end.
 diff --git a/plugins/mRadio/mradio.dpr b/plugins/mRadio/mradio.dpr index 1039ead40e..d8b0432b18 100644 --- a/plugins/mRadio/mradio.dpr +++ b/plugins/mRadio/mradio.dpr @@ -344,5 +344,7 @@ exports    Load, Unload,
    MirandaPluginInfoEx;
 -begin
 +initialization
 +  DisableThreadLibraryCalls(hInstance);
 +
  end.
  | 
