Changeset 1516 for trunk


Ignore:
Timestamp:
03/10/20 16:00:19 (4 years ago)
Author:
bnemhaus
Message:

Fixed an issue with saving (and subsequent loading) of new SampledTrack widgets.

Location:
trunk/src/org
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/apollo/widgets/SampledTrack.java

    r1434 r1516  
    814814               
    815815                if (trackModel != null && trackModel.getFilepath() != null &&
    816                                 trackModel.equals(f.getPath())) {
     816                                trackModel.getFilepath().equals(f.getPath())) {
    817817                       
    818818                        // already have loaded
     
    968968                // If saving for the file time then get a filename
    969969                if (trackModel.getFilepath() == null) {
    970                         File audioResource = ResourceManager.getAudioResource(localFileName, DisplayController.getCurrentFrame());
     970                        Frame parentFrame = this.getParentFrame();
     971                        File audioResource = ResourceManager.getAudioUnusedFilename(localFileName, parentFrame);
    971972                        trackModel.setFilepath(audioResource.getAbsolutePath());
    972973                        loadFilenameArgument = localFileName; // set to now local, next load will be local
     
    10601061                //File oldLocalFile = new File(AudioPathManager.AUDIO_HOME_DIRECTORY + localFileName);
    10611062                File oldLocalFile = ResourceManager.getAudioResource(localFileName, getParentFrame());
     1063               
     1064                if (oldLocalFile == null) {
     1065                        //It was never saved and therefore does not need to be deleted.
     1066                        return;
     1067                }
     1068               
    10621069                if (oldLocalFile.isFile() && oldLocalFile.exists()) {
    10631070                        try {
  • trunk/src/org/expeditee/gui/management/ResourceManager.java

    r1512 r1516  
    223223        }
    224224       
     225       
     226        public static File getAudioUnusedFilename(String fileName, Frame parentFrame) {
     227                List<String> directories = audio.getDirectories(parentFrame);
     228                directories.add(FrameIO.PARENT_FOLDER);
     229                for (String directory: directories) {
     230                        Path p = Paths.get(directory).resolve(fileName);
     231                        File file = p.toFile();
     232                        if (!file.exists()) {
     233                                return file;
     234                        }
     235                }
     236               
     237                return null;
     238        }
     239       
    225240        public static void invalidateAllResourceDirectories() {
    226241                commonInvalidated = true;
     
    230245                Frame currentFrame = DisplayController.getCurrentFrame();
    231246                String framesetPath = currentFrame == null ? null : currentFrame.getFramesetPath();
    232                 frames.refresh(framesetPath);
    233                 images.refresh(framesetPath);
    234                 audio.refresh(framesetPath);
     247                refreshAll(framesetPath);
     248        }
     249       
     250        private static void refreshAll(String contextPath) {
     251                frames.refresh(contextPath);
     252                images.refresh(contextPath);
     253                audio.refresh(contextPath);
    235254        }
    236255       
     
    259278                private List<String> getDirectories(String context) {
    260279                        if (commonInvalidated) {
    261                                 ResourceManager.refreshAll();
     280                                ResourceManager.refreshAll(context);
    262281                        } else {       
    263282                                boolean requiresRefresh = context == null || contextFramesetPath == null || !contextFramesetPath.equals(context);
Note: See TracChangeset for help on using the changeset viewer.