Changeset 1335 for trunk/dll/treecnr.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/treecnr.c

    r1326 r1335  
     1
    12/***********************************************************************
    23
     
    5051  19 Oct 08 GKY Fixed context menu to be "drives" menu on unformatted drives
    5152  28 Nov 08 GKY Remove unneeded DosEnterCriSec calls
     53  10 Dec 08 SHL Integrate exception handler support
    5254
    5355***********************************************************************/
     
    5658#include <string.h>
    5759#include <ctype.h>
    58 #include <process.h>                    // _beginthread
     60// #include <process.h>                 // _beginthread
    5961
    6062#define INCL_DOS
     
    7981#include "notebook.h"                   // CfgDlgProc
    8082#include "command.h"                    // RunCommand
    81 #include "worker.h"                     // Action, MassAction
     83#include "worker.h"             // Action, MassAction
    8284#include "mainwnd.h"                    // BubbleHelp, FindDirCnrByName, GetNextWindowPos
    8385#include "misc.h"                       // CnrDirectEdit, EmphasizeButton, FindDirCnr
    84                                         // FindDirCnr, FixSwitchList, OpenEdit, QuickPopup
    85                                         // SetSortChecks, SwitchCommand, CheckMenu
    86                                         // CurrentRecord, IsFm2Window
     86                                // FindDirCnr, FixSwitchList, OpenEdit, QuickPopup
     87                                // SetSortChecks, SwitchCommand, CheckMenu
     88                                // CurrentRecord, IsFm2Window
    8789#include "common.h"                     // CommonCnrProc, CommonDriveCmd, CommonFrameWndProc
    88                                         // CommonTextProc
     90                                // CommonTextProc
    8991#include "valid.h"                      // CheckDrive, DriveFlagsOne, IsValidDrive
    9092#include "chklist.h"                    // DropListProc
     
    116118#include "fortify.h"
    117119#include "init.h"                       // GetTidForWindow
     120#include "excputil.h"                   // xbeginthread
    118121
    119122// Data definitions
     
    614617    // DbgMsg(pszSrcFile, __LINE__, "UM_SHOWME mp1 %p mp2 %p", mp1, mp2);       // 14 Aug 07 SHL fixme
    615618    if (mp1) {
     619#     ifdef FORTIFY
     620      Fortify_BecomeOwner(mp1);
     621#     endif
    616622      dcd = INSTDATA(hwnd);
    617623      // DbgMsg(pszSrcFile, __LINE__, "UM_SHOWME dcd %p", dcd); // 14 Aug 07 SHL fixme
     
    809815      WinSendMsg(dcd->hwndCnr,
    810816                 CM_SCROLLWINDOW,
    811                 MPFROMSHORT(CMA_HORIZONTAL), MPFROMLONG(-1));
     817                MPFROMSHORT(CMA_HORIZONTAL), MPFROMLONG(-1));
    812818      //if (!fInitialDriveScan) {
    813         //DosWaitEventSem(DriveScanStart, 20000);
    814         while (StubbyScanCount != 0)
    815             DosSleep(50);
    816         /*pulPostCt = xmallocz(sizeof(ULONG), pszSrcFile, __LINE__);
    817         if (pulPostCt) {
    818           DosResetEventSem(DriveScanStart, pulPostCt);
    819           free(pulPostCt);
    820         } */
     819        //DosWaitEventSem(DriveScanStart, 20000);
     820        while (StubbyScanCount != 0)
     821            DosSleep(50);
     822        /*pulPostCt = xmallocz(sizeof(ULONG), pszSrcFile, __LINE__);
     823        if (pulPostCt) {
     824          DosResetEventSem(DriveScanStart, pulPostCt);
     825          free(pulPostCt);
     826        } */
    821827      //}
    822828      //else
     
    884890          wk->li = (LISTINFO *) mp1;
    885891          strcpy(wk->directory, dcd->directory);
    886           if (_beginthread(MassAction, NULL, 122880, (PVOID) wk) == -1) {
    887             Runtime_Error(pszSrcFile, __LINE__,
    888                           GetPString(IDS_COULDNTSTARTTHREADTEXT));
     892          if (xbeginthread(MassAction,
     893                           122880,
     894                           wk,
     895                           pszSrcFile,
     896                           __LINE__) == -1)
     897          {
    889898            free(wk);
    890899            FreeListInfo((LISTINFO *) mp1);
     
    922931          wk->li = (LISTINFO *) mp1;
    923932          strcpy(wk->directory, dcd->directory);
    924           if (_beginthread(Action, NULL, 122880, (PVOID) wk) == -1) {
    925             Runtime_Error(pszSrcFile, __LINE__,
    926                           GetPString(IDS_COULDNTSTARTTHREADTEXT));
     933          if (xbeginthread(Action,
     934                           122880,
     935                           wk,
     936                           pszSrcFile,
     937                           __LINE__) == -1)
     938          {
    927939            free(wk);
    928940            FreeListInfo((LISTINFO *) mp1);
     
    11301142      pci = (PCNRITEM) CurrentRecord(hwnd);
    11311143      if (pci && (INT) pci != -1) {
    1132         if (IsRoot(pci->pszFileName) || !DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
    1133                                                        FSIL_ALLOC, &fsa,
    1134                                                        sizeof(FSALLOCATE)))
     1144        if (IsRoot(pci->pszFileName) || !DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
     1145                                                       FSIL_ALLOC, &fsa,
     1146                                                       sizeof(FSALLOCATE)))
    11351147          menuHwnd = CheckMenu(hwndMainMenu, &TreeMenu, TREE_POPUP);
    11361148        else {
     
    12561268
    12571269  case UM_SETUP:
     1270#   ifdef FORTIFY
     1271    // Balance WM_DESTROY
     1272    Fortify_EnterScope();
     1273#   endif
     1274
    12581275    if (!dcd) {
    12591276      Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
     
    13141331                   MPFROMLONG(CMA_FLWINDOWATTR | CMA_LINESPACING |
    13151332                              CMA_CXTREEINDENT | CMA_PSORTRECORD));
    1316         if (_beginthread(MakeObjWin, NULL, 327680, (PVOID) dcd) == -1) {
    1317           Runtime_Error(pszSrcFile, __LINE__,
    1318                         GetPString(IDS_COULDNTSTARTTHREADTEXT));
     1333        if (xbeginthread(MakeObjWin,
     1334                         327680,
     1335                         dcd,
     1336                         pszSrcFile,
     1337                         __LINE__) == -1)
     1338        {
    13191339          PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
    1320           // return 0;
    13211340        }
    13221341        else
     
    24402459          pci = (PCNRITEM) CurrentRecord(hwnd);
    24412460          if (pci && (INT) pci != -1) {
    2442             pszTempDir = xstrdup(pci->pszFileName, pszSrcFile, __LINE__);
    2443             if (pszTempDir)
     2461            pszTempDir = xstrdup(pci->pszFileName, pszSrcFile, __LINE__);
     2462            if (pszTempDir)
    24442463              MakeValidDir(pszTempDir);
    24452464          }
    24462465          else
    2447             pszTempDir = xstrdup(pFM2SaveDirectory, pszSrcFile, __LINE__);
    2448           if (pszTempDir) {
    2449             if (WinDlgBox(HWND_DESKTOP, dcd->hwndParent,
    2450                           WalkAllDlgProc,
    2451                           FM3ModHandle, WALK_FRAME, MPFROMP(pszTempDir))) {
    2452               if (!WinSendMsg(hwnd, UM_SHOWME, MPFROMP(pszTempDir), MPFROMLONG(1)))
    2453                 free(pszTempDir);
    2454             }
    2455             else
    2456               free(pszTempDir);
    2457           }
     2466            pszTempDir = xstrdup(pFM2SaveDirectory, pszSrcFile, __LINE__);
     2467          if (pszTempDir) {
     2468            if (WinDlgBox(HWND_DESKTOP, dcd->hwndParent,
     2469                          WalkAllDlgProc,
     2470                          FM3ModHandle, WALK_FRAME, MPFROMP(pszTempDir))) {
     2471              if (!WinSendMsg(hwnd, UM_SHOWME, MPFROMP(pszTempDir), MPFROMLONG(1)))
     2472                free(pszTempDir);
     2473            }
     2474            else
     2475              free(pszTempDir);
     2476          }
    24582477        }
    24592478        break;
     
    30313050
    30323051  case WM_DESTROY:
     3052#   ifdef FORTIFY
     3053    DbgMsg(pszSrcFile, __LINE__, "WM_DESTROY hwnd %p TID %u", hwnd, GetTidForThread()); // 18 Jul 08 SHL fixme
     3054#   endif
    30333055    if (TreeCnrMenu)
    30343056      WinDestroyWindow(TreeCnrMenu);
     
    30503072    }
    30513073#   ifdef FORTIFY
    3052     // if (dcd)
    3053     //  Fortify_ChangeScope(dcd, -1);
    30543074    Fortify_LeaveScope();
    3055     // if (dcd)
    3056     //  Fortify_ChangeScope(dcd, -1);
    30573075#   endif
    30583076    break; // WM_DESTROY
     
    31213139        if (!WinCreateWindow(hwndFrame,
    31223140                             WC_TREEOPENBUTTON,
    3123                              "#303",
     3141                             "#303",
    31243142                             WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS | BS_BITMAP,
    31253143                             ((swp.cx -
Note: See TracChangeset for help on using the changeset viewer.