Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug with previous enhancement #128

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion workbench/libs/datatypes/lockdatatype.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "datatypes_intern.h"
#include <datatypes/datatypes.h>
#include <proto/exec.h>
//#define DEBUG 1
#include <aros/debug.h>

/*****************************************************************************

Expand Down Expand Up @@ -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);
Expand Down
8 changes: 5 additions & 3 deletions workbench/libs/datatypes/obtaindatatypea.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <dos/dos.h>
#include <datatypes/datatypesclass.h>
#include <libraries/iffparse.h>

//#define DEBUG 1
#include <aros/debug.h>

static inline struct DataType *DataTypeFromANode(struct Node *aNode)
Expand Down Expand Up @@ -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;

Expand Down
30 changes: 18 additions & 12 deletions workbench/libs/datatypes/releasedatatype.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "datatypes_intern.h"
#include <proto/exec.h>
#include <exec/alerts.h>
//#define DEBUG 1
#include <aros/debug.h>

/*****************************************************************************

Expand Down Expand Up @@ -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 */
100 changes: 58 additions & 42 deletions workbench/utilities/MultiView/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

#include "global.h"
#include "compilerspecific.h"
#include "debug.h"
//#define DEBUG 1
#include <aros/debug.h>
#include "arossupport.h"

#include <setjmp.h>
Expand Down Expand Up @@ -213,8 +214,8 @@ void Cleanup(CONST_STRPTR msg)
if (cd != BNULL)
CurrentDir(cd); /* restore current directory */

CloseLibs();
CleanupLocale();
CloseLibs();

longjmp(exit_buf, 0);
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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 */
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 */
Expand All @@ -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();

Expand Down