1010
1111#include "global.h"
1212#include "compilerspecific.h"
13- #include "debug.h"
13+ //#define DEBUG 1
14+ #include <aros/debug.h>
1415#include "arossupport.h"
1516
1617#include <setjmp.h>
@@ -213,8 +214,8 @@ void Cleanup(CONST_STRPTR msg)
213214 if (cd != BNULL )
214215 CurrentDir (cd ); /* restore current directory */
215216
216- CloseLibs ();
217217 CleanupLocale ();
218+ CloseLibs ();
218219
219220 longjmp (exit_buf , 0 );
220221}
@@ -371,8 +372,18 @@ static void GetFileToolTypes(STRPTR fname)
371372 char * s ;
372373
373374 D (bug ("[MultiView] %s()\n" , __func__ ));
374-
375- if ((fname ) && (dobj = GetDiskObject (fname )))
375+ if (!fname )
376+ return ;
377+
378+ D (bug ("[Multiview] Checking ToolTypes in filename = '%s.info'\n" , fname ));
379+
380+ dobj = GetDiskObject (fname );
381+ if (!dobj )
382+ {
383+ char errtext [81 ];
384+ Fault (IoErr (), "GetDiskObject() Failed" , errtext , 80 );
385+ }
386+ else
376387 {
377388 /* We have read the DiskObject (icon) for this arg */
378389 toolarray = (char * * )dobj -> do_ToolTypes ;
@@ -736,7 +747,7 @@ static void OpenDTO(void)
736747
737748 do
738749 {
739- D (bug ("[MultiView] calling NewDTObject\n" ));
750+ D (bug ("[MultiView] %s calling NewDTObject\n" , __func__ ));
740751
741752 if (!old_dto && bClipBoard )
742753 {
@@ -754,7 +765,7 @@ static void OpenDTO(void)
754765 DTA_TextAttr , (IPTR )& textattr ,
755766 TAG_DONE );
756767 }
757- D (bug ("[MultiView] NewDTObject returned %x\n" , dto ));
768+ D (bug ("[MultiView] %s NewDTObject returned %x\n" , __func__ , dto ));
758769
759770 if (!dto )
760771 {
@@ -768,6 +779,7 @@ static void OpenDTO(void)
768779 struct DataType * dtn ;
769780 if ((dtn = ObtainDataTypeA (DTST_FILE , (APTR )lock , NULL )))
770781 {
782+ D (bug ("[MultiView] %s ObtainDataTypeA returned %x\n" , __func__ , dtn ));
771783 if (!Stricmp (dtn -> dtn_Header -> dth_Name , "directory" ))
772784 {
773785 /* file is a directory and no directory.datatype is installed */
@@ -784,15 +796,17 @@ static void OpenDTO(void)
784796 filename = GetFileName (MSG_ASL_OPEN_TITLE );
785797 if (filename )
786798 {
799+ D (bug ("[MultiView] %s calling ReleaseDataType(%x)\n" , __func__ , dtn ));
787800 ReleaseDataType (dtn );
788801 UnLock (lock );
789802 continue ;
790803 }
791804 }
805+ D (bug ("[MultiView] %s calling ReleaseDataType(%x)\n" , __func__ , dtn ));
792806 ReleaseDataType (dtn );
793807 }
794808 UnLock (lock );
795- }
809+ }
796810 }
797811
798812 if (errnum >= DTERROR_UNKNOWN_DATATYPE )
@@ -931,6 +945,7 @@ static void OpenDTO(void)
931945 if (old_dto )
932946 {
933947 if (win ) RemoveDTObject (win , old_dto );
948+ D (bug ("[MultiView] %s: calling DisposeDTOObject(%x)\n" , __func__ , old_dto ));
934949 DisposeDTObject (old_dto );
935950
936951 if (win )
@@ -975,6 +990,7 @@ static void CloseDTO(void)
975990 if (dto )
976991 {
977992 if (win ) RemoveDTObject (win , dto );
993+ D (bug ("[MultiView] %s: calling DisposeDTOObject(%x)\n" , __func__ , dto ));
978994 DisposeDTObject (dto );
979995 dto = NULL ;
980996 }
@@ -1810,49 +1826,46 @@ int main(int argc, char **argv)
18101826 tdt_text_wordwrap = TRUE;
18111827 separate_screen = FALSE;
18121828
1829+ OpenLibs ();
18131830 InitDefaultFont (); /* May be overridden in GetArguments() if user specifies a font */
18141831 InitLocale ("System/Utilities/MultiView.catalog" , 2 );
18151832 InitMenus (nm );
18161833 InitMenus (nmpict );
18171834 InitMenus (nmtext );
1818- OpenLibs ();
18191835
18201836 if (FromWb )
18211837 {
18221838 WBenchMsg = (struct WBStartup * ) argv ;
1823- wbarg = WBenchMsg -> sm_ArgList ;
1824-
1825- /* Note wbarg++ at end of FOR statement steps through wbargs.
1826- * First arg is our executable (tool). Any additional args
1827- * are projects/icons passed to us via either extend select
1828- * or default tool method.
1829- * In our case, we only care about 2nd arg which is the filename
1830- */
1831-
1839+ char filepath [256 ];
1840+
18321841 if ( WBenchMsg -> sm_NumArgs > 0 )
1833- {
1834- /* Pass 1 gets any Tooltypes from MultiView Icon
1835- Pass 2 gets any Tooltypes from file icon, overlaying MultiView Icon Tooltypes
1836- */
1837- for (int i = 0 ; i < 2 && i < WBenchMsg -> sm_NumArgs ; i ++ )
1842+ {
1843+ wbarg = WBenchMsg -> sm_ArgList ;
1844+ /* Look at icon for Multiview program */
1845+ if (wbarg -> wa_Lock )
18381846 {
1839- if ( * wbarg -> wa_Name )
1840- {
1841- /* if there's a directory lock for this wbarg, CD there */
1842- cd = -1 ;
1843- if (wbarg -> wa_Lock )
1844- cd = CurrentDir (wbarg -> wa_Lock );
1845-
1846- if (i > 0 )
1847- filename = wbarg -> wa_Name ;
1848-
1849- GetFileToolTypes (wbarg -> wa_Name );
1850-
1851- if (cd != -1 )
1852- CurrentDir (cd ); /* CD back where we were */
1853- }
1854- wbarg ++ ;
1847+ NameFromLock (wbarg -> wa_Lock , filepath , 256 );
1848+ strcat (filepath ,"/" );
1849+ strcat (filepath , wbarg -> wa_Name );
1850+ GetFileToolTypes (filepath ); /*defaults from Multiview Icon*/
18551851 }
1852+ else
1853+ D (bug ("[MultiView] No wa_lock exits for program = %s\n" , wbarg -> wa_Name ));
1854+ }
1855+ if ( WBenchMsg -> sm_NumArgs > 1 )
1856+ {
1857+ wbarg ++ ; /* skip to input file */
1858+ D (bug ("[MultiView] filename = %s\n" , wbarg -> wa_Name ));
1859+ if (wbarg -> wa_Lock )
1860+ {
1861+ NameFromLock (wbarg -> wa_Lock , filepath , 256 );
1862+ strcat (filepath ,"/" );
1863+ strcat (filepath , wbarg -> wa_Name );
1864+ filename = filepath ;
1865+ D (bug ("[MultiView] Fully qualified filename = %s\n" , filename ));
1866+ }
1867+ else
1868+ D (bug ("[MultiView] No lock exits for filename = %s\n" , wbarg -> wa_Name ));
18561869 }
18571870 }
18581871 else /* from CLI */
@@ -1861,17 +1874,20 @@ int main(int argc, char **argv)
18611874 {
18621875 Fault (IoErr (), 0 , s , 256 );
18631876 Cleanup (s );
1864- }
1865- GetArguments ();
1877+ }
1878+
1879+ GetArguments (); /* get filename and other options also */
18661880 }
18671881
1882+ /* if running with no filename, then maybe bring up a requester */
18681883 if (!filename && bRequester && !bWindow && !bClipBoard )
18691884 filename = GetFileName (MSG_ASL_OPEN_TITLE );
18701885
1871- if (filename )
1886+ /* did we select a file ? If so, check to see if it has an icon to get options from*/
1887+ if (filename )
18721888 GetFileToolTypes (filename );
18731889
1874- /* ensure CLI parms beat icon parms */
1890+ /* ensure CLI parms (other than filename) beat icon parms */
18751891 if (!FromWb )
18761892 GetArguments ();
18771893
0 commit comments