Changeset 1335 for trunk/dll/dircnrs.c


Ignore:
Timestamp:
Dec 13, 2008, 12:49:02 AM (17 years ago)
Author:
Steven Levine
Message:

Ticket 26: Add exception handlers to all threads using xbeginthread

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/dircnrs.c

    r1318 r1335  
     1
    12/***********************************************************************
    23
     
    4445                DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS.
    4546  20 Jul 08 GKY Add save/append filename to clipboard.
    46                 Change menu wording to make these easier to find
     47                Change menu wording to make these easier to find
    4748  02 Aug 08 GKY Always pass temp variable point to treecnr UM_SHOWME to avoid
    48                 freeing dcd->directory early
     49                freeing dcd->directory early
    4950  25 Aug 08 GKY Check TMP directory space warn if lee than 5 MiB prevent archiver from opening if
    50                 less than 10 KiB (It hangs and can't be closed)
     51                less than 10 KiB (It hangs and can't be closed)
    5152  29 Nov 08 GKY Remove or replace with a mutex semaphore DosEnterCriSec where appropriate.
     53  10 Dec 08 SHL Integrate exception handler support
    5254
    5355***********************************************************************/
     
    5759#include <ctype.h>
    5860#include <limits.h>
    59 #include <process.h>                    // _beginthread
     61// #include <process.h>                 // _beginthread
    6062
    6163#define INCL_DOS
     
    8385#include "notebook.h"                   // CfgDlgProc
    8486#include "command.h"                    // RunCommand
    85 #include "worker.h"                     // Action, MassAction
     87#include "worker.h"             // Action, MassAction
    8688#include "misc.h"                       // GetTidForThread, AdjustCnrColsForFSType, AdjustCnrColsForPref
    87                                         // AdjustDetailsSwitches, CnrDirectEdit, OpenEdit, QuickPopup
    88                                         // SayFilter, SaySort, SayView, SetCnrCols, SetDetailsSwitches
    89                                         // SetSortChecks, SetViewMenu, SwitchCommand, CheckMenu
    90                                         // CurrentRecord, DrawTargetEmphasis, IsFm2Window
     89                                        // AdjustDetailsSwitches, CnrDirectEdit, OpenEdit, QuickPopup
     90                                        // SayFilter, SaySort, SayView, SetCnrCols, SetDetailsSwitches
     91                                // SetSortChecks, SetViewMenu, SwitchCommand, CheckMenu
     92                                // CurrentRecord, DrawTargetEmphasis, IsFm2Window
    9193#include "chklist.h"                    // CenterOverWindow, DropListProc
    9294#include "common.h"                     // CommonCnrProc, CommonCreateTextChildren, CommonFrameWndProc
    93                                         // CommonTextPaint, CommonTextButton, CommonTextProc
     95                                // CommonTextPaint, CommonTextButton, CommonTextProc
    9496#include "mainwnd.h"                    // CountDirCnrs, GetNextWindowPos, MakeBubble, TopWindow
    9597#include "select.h"                     // DeselectAll, HideAll, InvertAll, SelectAll, SelectList
    96                                         // SpecialSelect2
     98                                // SpecialSelect2
    9799#include "dirsize.h"                    // DirSizeProc
    98100#include "flesh.h"                      // Flesh, Stubby, UnFlesh
     
    126128#include "wrappers.h"                   // xfree
    127129#include "fortify.h"
     130#include "excputil.h"                   // 06 May 08 SHL added
    128131
    129132// Data definitions
     
    711714#     ifdef FORTIFY
    712715      Fortify_BecomeOwner(dcd);         // We free dcd
     716      if (GetTidForThread() != 1)
     717      Fortify_ChangeScope(dcd, -1);
    713718#     endif
    714719      /* set unique id */
     
    720725    else
    721726      PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
     727#   ifdef FORTIFY
     728    // TID 1 will free data
     729    if (GetTidForThread() != 1)
     730      Fortify_LeaveScope();
     731#   endif
    722732    return 0;
    723733
     
    780790                            MPFROMP(pci),
    781791                            MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
    782           if (!pciC) {
    783             Stubby(dcd->hwndCnr, pci);
     792          if (!pciC) {
     793            Stubby(dcd->hwndCnr, pci);
    784794            //DosSleep(1); //26 Aug 07 GKY 1
    785795          }
     
    787797        pci = WinSendMsg(dcd->hwndCnr,
    788798                         CM_QUERYRECORD,
    789                         MPFROMP(pci), MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
     799                        MPFROMP(pci), MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
    790800      }
    791801      dcd->firsttree = TRUE;
     
    804814        dcd->stopflag--;
    805815      if (dcd->stopflag) {
    806         DosReleaseMutexSem(hmtxFM2Globals);
    807         //DosExitCritSec();
     816        DosReleaseMutexSem(hmtxFM2Globals);
     817        //DosExitCritSec();
    808818        return 0;
    809819      }
     
    842852      }
    843853      if (fSwitchTree && hwndTree) {
    844         PSZ pszTempDir = xstrdup(dcd->directory, pszSrcFile, __LINE__);
    845 
    846         if (hwndMain) {
     854        PSZ pszTempDir = xstrdup(dcd->directory, pszSrcFile, __LINE__);
     855
     856        if (hwndMain) {
    847857          if (TopWindow(hwndMain, (HWND) 0) == dcd->hwndFrame && pszTempDir)
    848             if (!WinSendMsg(hwndTree, UM_SHOWME, MPFROMP(pszTempDir), MPVOID))
    849               free(pszTempDir);
    850         }
    851         else {
    852           if (pszTempDir)
    853             if (!WinSendMsg(hwndTree, UM_SHOWME, MPFROMP(pszTempDir), MPVOID))
    854               free(pszTempDir);
    855         }
     858            if (!WinSendMsg(hwndTree, UM_SHOWME, MPFROMP(pszTempDir), MPVOID))
     859              free(pszTempDir);
     860        }
     861        else {
     862          if (pszTempDir)
     863            if (!WinSendMsg(hwndTree, UM_SHOWME, MPFROMP(pszTempDir), MPVOID))
     864              free(pszTempDir);
     865        }
    856866      }
    857867      dcd->firsttree = FALSE;
     
    10851095          wk->li = (LISTINFO *) mp1;
    10861096          strcpy(wk->directory, dcd->directory);
    1087           if (_beginthread(MassAction, NULL, 122880, (PVOID) wk) == -1) {
    1088             Runtime_Error(pszSrcFile, __LINE__,
    1089                           GetPString(IDS_COULDNTSTARTTHREADTEXT));
     1097          if (xbeginthread(MassAction,
     1098                           122880,
     1099                           wk,
     1100                           pszSrcFile,
     1101                           __LINE__) == -1)
     1102          {
    10901103            free(wk);
    1091             FreeListInfo((LISTINFO *) mp1);
     1104            FreeListInfo((LISTINFO *)mp1);
    10921105          }
    10931106        }
     
    11211134          wk->li = (LISTINFO *) mp1;
    11221135          strcpy(wk->directory, dcd->directory);
    1123           if (_beginthread(Action, NULL, 122880, (PVOID) wk) == -1) {
     1136          if (xbeginthread(Action,
     1137                           122880,
     1138                           wk,
     1139                           pszSrcFile,
     1140                           __LINE__) == -1)
     1141          {
    11241142            Runtime_Error(pszSrcFile, __LINE__,
    11251143                          GetPString(IDS_COULDNTSTARTTHREADTEXT));
     
    11441162#   endif
    11451163    dcd = WinQueryWindowPtr(hwnd, QWL_USER);
    1146     if (dcd) {
     1164    if (!dcd)
     1165      Runtime_Error(pszSrcFile, __LINE__, "no data");
     1166    else {
    11471167      if (dcd->hwndRestore)
    11481168        WinSetWindowPos(dcd->hwndRestore,
     
    11551175      FreeList(dcd->lastselection);
    11561176      xfree(dcd, pszSrcFile, __LINE__);
    1157 #     ifdef FORTIFY
    1158       Fortify_LeaveScope();
    1159 #     endif
    11601177      WinSetWindowPtr(dcd->hwndCnr, QWL_USER, NULL);
    11611178      DosPostEventSem(CompactSem);
    11621179    }
     1180#   ifdef FORTIFY
     1181    Fortify_LeaveScope();
     1182#   endif
     1183    // 22 Jul 08 SHL fixme to understand
    11631184    if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
    11641185      WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
     
    14021423      PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
    14031424      if (fSwitchTreeOnFocus && hwndTree && dcd && *dcd->directory) {
    1404         PSZ pszTempDir = xstrdup(dcd->directory, pszSrcFile, __LINE__);
    1405 
    1406         if (pszTempDir) {
    1407           if (!WinSendMsg(hwndTree, UM_SHOWME, MPFROMP(pszTempDir), MPVOID))
    1408             free(pszTempDir);
    1409         }
     1425        PSZ pszTempDir = xstrdup(dcd->directory, pszSrcFile, __LINE__);
     1426
     1427        if (pszTempDir) {
     1428          if (!WinSendMsg(hwndTree, UM_SHOWME, MPFROMP(pszTempDir), MPVOID))
     1429            free(pszTempDir);
     1430        }
    14101431      }
    14111432    }
     
    16091630                              CMA_CXTREEINDENT | CMA_PSORTRECORD));
    16101631        SetCnrCols(hwnd, FALSE);
    1611         if (_beginthread(MakeObjWin, NULL, 245760, (PVOID) dcd) == -1) {
     1632        if (xbeginthread(MakeObjWin,
     1633                         245760,
     1634                         dcd,
     1635                         pszSrcFile,
     1636                         __LINE__) == -1)
     1637        {
    16121638          Runtime_Error(pszSrcFile, __LINE__,
    16131639                        GetPString(IDS_COULDNTSTARTTHREADTEXT));
     
    16641690      }
    16651691      else if (mp1 && IsFile(mp1) == 1 &&
    1666                CheckDriveSpaceAvail(ArcTempRoot, ullDATFileSpaceNeeded, ullTmpSpaceNeeded) != 2) {
     1692               CheckDriveSpaceAvail(ArcTempRoot, ullDATFileSpaceNeeded, ullTmpSpaceNeeded) != 2) {
    16671693        StartArcCnr(HWND_DESKTOP,
    16681694                    dcd->hwndFrame, (CHAR *)mp1, 4, (ARC_TYPE *) mp2);
     
    19171943
    19181944      case IDM_FINDINTREE:
    1919         if (hwndTree) {
    1920           PSZ pszTempDir = xstrdup(dcd->directory, pszSrcFile, __LINE__);
    1921 
    1922           if (pszTempDir) {
    1923             if (!WinSendMsg(hwndTree, UM_SHOWME, MPFROMP(pszTempDir),
    1924                             MPFROMLONG(1L)))
    1925               free(pszTempDir);
    1926           }
    1927         }
     1945        if (hwndTree) {
     1946          PSZ pszTempDir = xstrdup(dcd->directory, pszSrcFile, __LINE__);
     1947
     1948          if (pszTempDir) {
     1949            if (!WinSendMsg(hwndTree, UM_SHOWME, MPFROMP(pszTempDir),
     1950                            MPFROMLONG(1L)))
     1951              free(pszTempDir);
     1952          }
     1953        }
    19281954        break;
    19291955
     
    26622688              }
    26632689              switch (SHORT1FROMMP(mp1)) {
    2664               case IDM_APPENDTOCLIP:
    2665               case IDM_APPENDTOCLIPFILENAME:
    2666               case IDM_SAVETOCLIP:
    2667               case IDM_SAVETOCLIPFILENAME:
     2690              case IDM_APPENDTOCLIP:
     2691              case IDM_APPENDTOCLIPFILENAME:
     2692              case IDM_SAVETOCLIP:
     2693              case IDM_SAVETOCLIPFILENAME:
    26682694              case IDM_ARCHIVE:
    26692695              case IDM_ARCHIVEM:
     
    36563682            CommonCreateTextChildren(dcd->hwndClient,
    36573683                                     WC_DIRSTATUS, ids);
    3658           }
     3684          }
    36593685          if (!PostMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID))
    36603686            WinSendMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID);
Note: See TracChangeset for help on using the changeset viewer.