Datatypes functions crash

2 posts / 0 new
Last post
walkero
walkero's picture
Offline
Last seen: 4 months 3 weeks ago
Joined: 2009-05-03 16:54
Datatypes functions crash

I need to check if an image is supported by the installed datatypes, before I use it in GUI. So I thought to use the NewDTObject, and I wrote the checkImageDatatype() method to test it. Below you can see the code.

Although that this works great on AmigaOS 3 68k code, the AmigaOS 4 PPC version crashes the system at the NewDTObject() line.

  1. BOOL check_path_exists(char *path)
  2. {
  3. const BPTR lock = Lock(path, SHARED_LOCK);
  4. if (lock) {
  5. UnLock(lock);
  6. return TRUE;
  7. }
  8.  
  9. return FALSE;
  10. }
  11.  
  12. BOOL checkImageDatatype(STRPTR filename)
  13. {
  14. if (check_path_exists(filename))
  15. {
  16. Object *dtObj;
  17.  
  18. dtObj = NewDTObject(filename,
  19. DTA_SourceType, DTST_FILE,
  20. DTA_GroupID, GID_PICTURE,
  21. TAG_DONE);
  22.  
  23. if (dtObj)
  24. {
  25. DisposeDTObject (dtObj);
  26. return TRUE;
  27. }
  28. }
  29.  
  30. return FALSE;
  31. }

Then I tried to change the method with the following, but unfortunately, on AmigaOS 4 PPC version it crashes at the ObtainDataType() line again.

  1. BOOL checkImageDatatype(STRPTR filename)
  2. {
  3. BOOL result = FALSE;
  4. BPTR lock;
  5. struct DataType *dtn;
  6.  
  7. if((lock = Lock(filename, SHARED_LOCK)))
  8. {
  9. if((dtn = ObtainDataType(DTST_FILE, (APTR) lock, TAG_END)))
  10. {
  11. const struct DataTypeHeader *dth = dtn->dtn_Header;
  12. printf("Description: %s\n", dth->dth_Name);
  13. printf(" Group: %s\n", GetDTString(dth->dth_GroupID));
  14.  
  15. if (dth->dth_GroupID == GID_PICTURE)
  16. {
  17. result = TRUE;
  18. }
  19.  
  20. ReleaseDataType(dtn);
  21. }
  22. UnLock(lock);
  23. }
  24. return result;
  25. }

Any idea why the above works fine on AmigaOS 3 but crashes on AmigaOS 4? Anything I could check?

walkero
walkero's picture
Offline
Last seen: 4 months 3 weeks ago
Joined: 2009-05-03 16:54
Re: Datatypes functions crash

The issue is solved. I forgot to register the DataTypesIFace, that's why it was crashing only on OS4.
Found that issue thanks to Andy Broad who was kind to point me that way. Thanks Andy.

Log in or register to post comments