Changeset 1833 for trunk/dll/misc.c


Ignore:
Timestamp:
Jul 14, 2015, 1:07:26 AM (10 years ago)
Author:
Gregg Young
Message:

A correct (I hope as always) fix for the direct edits. I don't need to reallocate pci-pszFileName or repoint pci->pszDisplayName because updatecnritems does it for me. I also got the tree container to update without using removecnritems. Ticket [557]

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/misc.c

    r1829 r1833  
    7272  12 Nov 11 GKY Fixed HelpViewer's failure to open help files and subsequent failure with files with spaces.
    7373  28 Jun 14 GKY Fix errors identified with CPPCheck
    74   12 Jul 15 GKY Fix CN_REALLOCPSZ file name editing code to: 1) Actually reallocate the buffer.
    75                 2) Point pci->pszDisplayName into the new buffer 3) Eliminate the possibility
    76                 of updating the container before CN_ENDEDIT is called. 4) Only call RemoveCnrItems
     74  12 Jul 15 GKY Fix CN_REALLOCPSZ file name editing code to: 1) Eliminate the possibility of
     75                updating the container before CN_ENDEDIT is called. 2) Don't call RemoveCnrItems
    7776                for tree container and collector.
    7877
     
    979978            Runtime_Error(pszSrcFile, __LINE__, "bad name");
    980979          else {
    981             DIRCNRDATA *dcd;
    982             FILEFINDBUF4L ffb;
    983             HDIR hDir = HDIR_CREATE;
    984             ULONG nm = 1;
    985             CHAR *p;
    986 
    987980            if (DosQueryPathInfo(testname, //Why does this return 0 when the file doesn't exist?
    988981                                 FIL_QUERYFULLNAME, // No new directory creation?
     
    993986                                 oldname, sizeof(oldname)))
    994987              strcpy(oldname, pci->pszFileName);
    995             psz = xrealloc(pci->pszFileName, sizeof(oldname), pszSrcFile, __LINE__);
    996             if (psz)
    997               pci->pszFileName = psz;
    998             else {
    999               xfree(pci->pszFileName, pszSrcFile, __LINE__);
    1000               pci->pszFileName = NullStr;
    1001               return FALSE; // out of memory
    1002             }
    1003             if (!dcd)    // Point pci->pszDisplayName into the realloc pci->pszFileName
    1004               dcd = INSTDATA(hwnd);
    1005             rc = xDosFindFirst(pci->pszFileName,
    1006                                &hDir,
    1007                                FILE_NORMAL | FILE_DIRECTORY |
    1008                                FILE_ARCHIVED | FILE_READONLY |
    1009                                FILE_HIDDEN | FILE_SYSTEM,
    1010                                &ffb, sizeof(ffb), &nm, FIL_QUERYEASIZEL);
    1011             if (!rc) {  // file exists
    1012               DosFindClose(hDir);
    1013               if (dcd->type == DIR_FRAME || dcd->type == TREE_FRAME) {
    1014                 p = strrchr(pci->pszFileName, '\\');
    1015                 if (!p) {
    1016                   p = strrchr(pci->pszFileName, ':');
    1017                   if (!p)
    1018                     p = pci->pszFileName;
    1019                   else
    1020                     p++;
    1021                 }
    1022                 else if ((dcd && dcd->type == TREE_FRAME) ||
    1023                          !(ffb.attrFile & FILE_DIRECTORY) || !*(p + 1))
    1024                   p++;
    1025                 if (!*p)
    1026                   p = pci->pszFileName;
    1027               }
    1028               else
    1029                 p = pci->pszFileName;
    1030               pci->pszDisplayName = p;
    1031             }
    1032             else
    1033               return FALSE; // nothing to rename
    1034988            WinSetWindowText(hwndMLE, oldname);
    1035989            if (strcmp(oldname, newname)) {
     
    10761030            free(filename);
    10771031        }
    1078         if (dcd && (dcd->type == TREE_FRAME || dcd->type == COLLECTOR_FRAME))
    1079           PostMsg(hwnd, UM_FIXEDITNAME, MPFROMLONG(-1), MPFROMP(pci));
    10801032        filename = xstrdup(newname, pszSrcFile, __LINE__);
    10811033        if (filename) {
Note: See TracChangeset for help on using the changeset viewer.