Revision: 29057
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29057
Author:   broken
Date:     2010-05-29 01:16:25 +0200 (Sat, 29 May 2010)

Log Message:
-----------
Missed this in last commit (Fix Open Sound operator)

Modified Paths:
--------------
    trunk/blender/source/blender/editors/sound/sound_ops.c

Modified: trunk/blender/source/blender/editors/sound/sound_ops.c
===================================================================
--- trunk/blender/source/blender/editors/sound/sound_ops.c      2010-05-28 
23:12:45 UTC (rev 29056)
+++ trunk/blender/source/blender/editors/sound/sound_ops.c      2010-05-28 
23:16:25 UTC (rev 29057)
@@ -30,10 +30,13 @@
 #include <stdlib.h>
 #include <stdio.h>
 
+#include "MEM_guardedalloc.h"
+
 #include "DNA_packedFile_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_space_types.h"
 #include "DNA_sequence_types.h"
+#include "DNA_userdef_types.h"
 
 #include "BKE_context.h"
 #include "BKE_global.h"
@@ -61,17 +64,30 @@
 
 /******************** open sound operator ********************/
 
+static void open_init(bContext *C, wmOperator *op)
+{
+       PropertyPointerRNA *pprop;
+       
+       op->customdata= pprop= MEM_callocN(sizeof(PropertyPointerRNA), 
"OpenPropertyPointerRNA");
+       uiIDContextProperty(C, &pprop->ptr, &pprop->prop);
+}
+
 static int open_exec(bContext *C, wmOperator *op)
 {
        char path[FILE_MAX];
        bSound *sound;
+       PropertyPointerRNA *pprop;
+       PointerRNA idptr;
        AUD_SoundInfo info;
 
        RNA_string_get(op->ptr, "path", path);
-
        sound = sound_new_file(CTX_data_main(C), path);
 
+       if(!op->customdata)
+               open_init(C, op);
+       
        if (sound==NULL || sound->playback_handle == NULL) {
+               if(op->customdata) MEM_freeN(op->customdata);
                BKE_report(op->reports, RPT_ERROR, "Unsupported audio format");
                return OPERATOR_CANCELLED;
        }
@@ -80,6 +96,7 @@
 
        if (info.specs.channels == AUD_CHANNELS_INVALID) {
                sound_delete(C, sound);
+               if(op->customdata) MEM_freeN(op->customdata);
                BKE_report(op->reports, RPT_ERROR, "Unsupported audio format");
                return OPERATOR_CANCELLED;
        }
@@ -87,12 +104,33 @@
        if (RNA_boolean_get(op->ptr, "cache")) {
                sound_cache(sound, 0);
        }
+       
+       /* hook into UI */
+       pprop= op->customdata;
+       
+       if(pprop->prop) {
+               /* when creating new ID blocks, use is already 1, but RNA
+                * pointer se also increases user, so this compensates it */
+               sound->id.us--;
+               
+               RNA_id_pointer_create(&sound->id, &idptr);
+               RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr);
+               RNA_property_update(C, &pprop->ptr, pprop->prop);
+       }
 
        return OPERATOR_FINISHED;
 }
 
 static int open_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
+       if(!RNA_property_is_set(op->ptr, "relative_path"))
+               RNA_boolean_set(op->ptr, "relative_path", U.flag & 
USER_RELPATHS);
+       
+       if(RNA_property_is_set(op->ptr, "path"))
+               return open_exec(C, op);
+       
+       open_init(C, op);
+       
        return WM_operator_filesel(C, op, event);
 }
 
@@ -113,6 +151,7 @@
        /* properties */
        WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE|MOVIEFILE, 
FILE_SPECIAL, FILE_OPENFILE);
        RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Cache the sound in 
memory.");
+       RNA_def_boolean(ot->srna, "relative_path", FALSE, "Relative Path", 
"Load image with relative path to current .blend file");
 }
 
 /* ******************************************************* */


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to