diff --git a/workbench/libs/datatypes/lockdatatype.c b/workbench/libs/datatypes/lockdatatype.c index 063acc8deaa..226ee611464 100644 --- a/workbench/libs/datatypes/lockdatatype.c +++ b/workbench/libs/datatypes/lockdatatype.c @@ -7,6 +7,8 @@ #include "datatypes_intern.h" #include #include +//#define DEBUG 1 +#include /***************************************************************************** @@ -55,11 +57,14 @@ { AROS_LIBFUNC_INIT + D(bug("datatypes.library/LockDataType: Entered with datatype(%x)\n", dt)); + if(dt == NULL || dt->dtn_Length == 0) return; ObtainSemaphoreShared(&(GPB(DataTypesBase)->dtb_DTList)->dtl_Lock); - + + D(bug("datatypes.library/LockDataType: Datatype %x OpenCount being incremented to %d\n", dt, ((struct CompoundDataType *)dt)->OpenCount + 1)); ((struct CompoundDataType *)dt)->OpenCount++; ReleaseSemaphore(&(GPB(DataTypesBase)->dtb_DTList)->dtl_Lock); diff --git a/workbench/libs/datatypes/obtaindatatypea.c b/workbench/libs/datatypes/obtaindatatypea.c index c4df53291bd..156d4e1676b 100644 --- a/workbench/libs/datatypes/obtaindatatypea.c +++ b/workbench/libs/datatypes/obtaindatatypea.c @@ -11,7 +11,7 @@ #include #include #include - +//#define DEBUG 1 #include static inline struct DataType *DataTypeFromANode(struct Node *aNode) @@ -210,15 +210,17 @@ static inline struct DataType *DataTypeFromANode(struct Node *aNode) break; } - if(cdt) + if(cdt) { + D(bug("[datatypes.library/ObtainDataTypeA] : Datatype %x OpenCount being incremented to %d\n", cdt, cdt->OpenCount + 1)); cdt->OpenCount++; + } ReleaseSemaphore(&(GPB(DataTypesBase)->dtb_DTList->dtl_Lock)); if(IoErr() == ERROR_OBJECT_NOT_FOUND) SetIoErr(DTERROR_COULDNT_OPEN); - D(bug("datatypes.library/ObtainDataType: Done. Returning %x\n", cdt)); + D(bug("[datatypes.library/ObtainDataType] : Done. Returning %x\n", cdt)); return (struct DataType *)cdt; diff --git a/workbench/libs/datatypes/releasedatatype.c b/workbench/libs/datatypes/releasedatatype.c index 1281f513055..7a1d9fa509a 100644 --- a/workbench/libs/datatypes/releasedatatype.c +++ b/workbench/libs/datatypes/releasedatatype.c @@ -7,6 +7,8 @@ #include "datatypes_intern.h" #include #include +//#define DEBUG 1 +#include /***************************************************************************** @@ -50,17 +52,21 @@ { AROS_LIBFUNC_INIT - if(!dt) - return; - - ObtainSemaphoreShared(&(GPB(DataTypesBase)->dtb_DTList)->dtl_Lock); - - if(((struct CompoundDataType *)dt)->OpenCount) - ((struct CompoundDataType*)dt)->OpenCount--; - else - Alert(AN_Unknown); - - ReleaseSemaphore(&(GPB(DataTypesBase)->dtb_DTList)->dtl_Lock); - + D(bug("datatypes.library/ReleaseDataType: Entered with datatype(%x)\n", dt)); + + if (dt) + { + ObtainSemaphoreShared(&(GPB(DataTypesBase)->dtb_DTList)->dtl_Lock); + + if(((struct CompoundDataType *)dt)->OpenCount) + ((struct CompoundDataType*)dt)->OpenCount--; + else + { + D(bug("datatypes.library/ReleaseDataType : Datatype %x has invalid OpenCount value of %d\n", dt, ((struct CompoundDataType *)dt)->OpenCount)); + //Alert(AN_Unknown); + } + + ReleaseSemaphore(&(GPB(DataTypesBase)->dtb_DTList)->dtl_Lock); + } AROS_LIBFUNC_EXIT } /* ReleaseDataType */ diff --git a/workbench/utilities/MultiView/main.c b/workbench/utilities/MultiView/main.c index a709d2d14ae..47b215ce867 100644 --- a/workbench/utilities/MultiView/main.c +++ b/workbench/utilities/MultiView/main.c @@ -10,7 +10,8 @@ #include "global.h" #include "compilerspecific.h" -#include "debug.h" +//#define DEBUG 1 +#include #include "arossupport.h" #include @@ -213,8 +214,8 @@ void Cleanup(CONST_STRPTR msg) if (cd != BNULL) CurrentDir(cd); /* restore current directory */ - CloseLibs(); CleanupLocale(); + CloseLibs(); longjmp(exit_buf, 0); } @@ -371,8 +372,18 @@ static void GetFileToolTypes(STRPTR fname) char *s; D(bug("[MultiView] %s()\n", __func__)); - - if ((fname) && (dobj=GetDiskObject(fname))) + if (!fname) + return; + + D(bug("[Multiview] Checking ToolTypes in filename = '%s.info'\n", fname)); + + dobj=GetDiskObject(fname); + if (!dobj) + { + char errtext[81]; + Fault(IoErr(), "GetDiskObject() Failed", errtext, 80); + } + else { /* We have read the DiskObject (icon) for this arg */ toolarray = (char **)dobj->do_ToolTypes; @@ -736,7 +747,7 @@ static void OpenDTO(void) do { - D(bug("[MultiView] calling NewDTObject\n")); + D(bug("[MultiView] %s calling NewDTObject\n", __func__)); if (!old_dto && bClipBoard) { @@ -754,7 +765,7 @@ static void OpenDTO(void) DTA_TextAttr , (IPTR)&textattr, TAG_DONE); } - D(bug("[MultiView] NewDTObject returned %x\n", dto)); + D(bug("[MultiView] %s NewDTObject returned %x\n", __func__, dto)); if (!dto) { @@ -768,6 +779,7 @@ static void OpenDTO(void) struct DataType *dtn; if ((dtn = ObtainDataTypeA(DTST_FILE, (APTR)lock, NULL))) { + D(bug("[MultiView] %s ObtainDataTypeA returned %x\n", __func__, dtn)); if (!Stricmp(dtn->dtn_Header->dth_Name, "directory")) { /* file is a directory and no directory.datatype is installed */ @@ -784,15 +796,17 @@ static void OpenDTO(void) filename = GetFileName(MSG_ASL_OPEN_TITLE); if (filename) { + D(bug("[MultiView] %s calling ReleaseDataType(%x)\n", __func__, dtn)); ReleaseDataType(dtn); UnLock(lock); continue; } } + D(bug("[MultiView] %s calling ReleaseDataType(%x)\n", __func__, dtn)); ReleaseDataType(dtn); } UnLock(lock); - } + } } if (errnum >= DTERROR_UNKNOWN_DATATYPE) @@ -931,6 +945,7 @@ static void OpenDTO(void) if (old_dto) { if (win) RemoveDTObject(win, old_dto); + D(bug("[MultiView] %s: calling DisposeDTOObject(%x)\n", __func__, old_dto)); DisposeDTObject(old_dto); if (win) @@ -975,6 +990,7 @@ static void CloseDTO(void) if (dto) { if (win) RemoveDTObject(win, dto); + D(bug("[MultiView] %s: calling DisposeDTOObject(%x)\n", __func__, dto)); DisposeDTObject(dto); dto = NULL; } @@ -1810,49 +1826,46 @@ int main(int argc, char **argv) tdt_text_wordwrap = TRUE; separate_screen = FALSE; + OpenLibs(); InitDefaultFont(); /* May be overridden in GetArguments() if user specifies a font */ InitLocale("System/Utilities/MultiView.catalog", 2); InitMenus(nm); InitMenus(nmpict); InitMenus(nmtext); - OpenLibs(); if (FromWb) { WBenchMsg = (struct WBStartup *) argv; - wbarg = WBenchMsg->sm_ArgList; - - /* Note wbarg++ at end of FOR statement steps through wbargs. - * First arg is our executable (tool). Any additional args - * are projects/icons passed to us via either extend select - * or default tool method. - * In our case, we only care about 2nd arg which is the filename - */ - + char filepath[256]; + if ( WBenchMsg->sm_NumArgs > 0) - { - /* Pass 1 gets any Tooltypes from MultiView Icon - Pass 2 gets any Tooltypes from file icon, overlaying MultiView Icon Tooltypes - */ - for (int i = 0; i < 2 && i < WBenchMsg->sm_NumArgs; i++) + { + wbarg = WBenchMsg->sm_ArgList; + /* Look at icon for Multiview program */ + if (wbarg->wa_Lock) { - if ( *wbarg->wa_Name ) - { - /* if there's a directory lock for this wbarg, CD there */ - cd = -1; - if (wbarg->wa_Lock) - cd = CurrentDir(wbarg->wa_Lock); - - if (i > 0 ) - filename = wbarg->wa_Name; - - GetFileToolTypes(wbarg->wa_Name); - - if (cd != -1) - CurrentDir(cd); /* CD back where we were */ - } - wbarg++; + NameFromLock(wbarg->wa_Lock, filepath, 256); + strcat(filepath,"/"); + strcat(filepath, wbarg->wa_Name); + GetFileToolTypes(filepath); /*defaults from Multiview Icon*/ } + else + D(bug("[MultiView] No wa_lock exits for program = %s\n", wbarg->wa_Name)); + } + if ( WBenchMsg->sm_NumArgs > 1) + { + wbarg++; /* skip to input file */ + D(bug("[MultiView] filename = %s\n", wbarg->wa_Name)); + if (wbarg->wa_Lock) + { + NameFromLock(wbarg->wa_Lock, filepath, 256); + strcat(filepath,"/"); + strcat(filepath, wbarg->wa_Name); + filename = filepath; + D(bug("[MultiView] Fully qualified filename = %s\n", filename)); + } + else + D(bug("[MultiView] No lock exits for filename = %s\n", wbarg->wa_Name)); } } else /* from CLI */ @@ -1861,17 +1874,20 @@ int main(int argc, char **argv) { Fault(IoErr(), 0, s, 256); Cleanup(s); - } - GetArguments(); + } + + GetArguments(); /* get filename and other options also */ } + /* if running with no filename, then maybe bring up a requester */ if (!filename && bRequester && !bWindow && !bClipBoard) filename = GetFileName(MSG_ASL_OPEN_TITLE); - if (filename) + /* did we select a file ? If so, check to see if it has an icon to get options from*/ + if (filename) GetFileToolTypes(filename); - /* ensure CLI parms beat icon parms */ + /* ensure CLI parms (other than filename) beat icon parms */ if (!FromWb) GetArguments();