svn merge ^/trunk/blender -r48415:48469
[blender.git] / source / blender / imbuf / intern / allocimbuf.c
index 68a094c26d0b13cc1c3fd61474edd4d9ab3ba180..0545bb33cb3d209589a7db30003e0ddb5cd91be6 100644 (file)
@@ -41,6 +41,7 @@
 #include "IMB_allocimbuf.h"
 #include "IMB_filetype.h"
 #include "IMB_metadata.h"
 #include "IMB_allocimbuf.h"
 #include "IMB_filetype.h"
 #include "IMB_metadata.h"
+#include "IMB_colormanagement.h"
 
 #include "imbuf.h"
 
 
 #include "imbuf.h"
 
@@ -162,8 +163,12 @@ void IMB_freeImBuf(ImBuf *ibuf)
                        IMB_freezbuffloatImBuf(ibuf);
                        freeencodedbufferImBuf(ibuf);
                        IMB_metadata_free(ibuf);
                        IMB_freezbuffloatImBuf(ibuf);
                        freeencodedbufferImBuf(ibuf);
                        IMB_metadata_free(ibuf);
-                       if (ibuf->dds_data.data != NULL)
+                       IMB_colormanage_flags_free(ibuf);
+                       IMB_colormanage_cache_data_free(ibuf);
+
+                       if (ibuf->dds_data.data != NULL) {
                                free(ibuf->dds_data.data); /* dds_data.data is allocated by DirectDrawSurface::readData(), so don't use MEM_freeN! */
                                free(ibuf->dds_data.data); /* dds_data.data is allocated by DirectDrawSurface::readData(), so don't use MEM_freeN! */
+                       }
                        MEM_freeN(ibuf);
                }
        }
                        MEM_freeN(ibuf);
                }
        }
@@ -442,7 +447,12 @@ ImBuf *IMB_dupImBuf(ImBuf *ibuf1)
        tbuf.metadata = NULL;
 
        *ibuf2 = tbuf;
        tbuf.metadata = NULL;
 
        *ibuf2 = tbuf;
-       
+
+       IMB_display_buffer_invalidate(ibuf2);
+       IMB_colormanage_cache_data_free(ibuf2);
+
+       ibuf2->colormanage_flags &= ~ IMB_COLORMANAGED;
+
        return(ibuf2);
 }
 
        return(ibuf2);
 }