https://bugs.documentfoundation.org/show_bug.cgi?id=151932

            Bug ID: 151932
           Summary: GalleryItem ( XGalleryItem ) wipes some of its
                    properties as soon as it is returned from a funciton.
           Product: LibreOffice
           Version: 7.3.6.2 release
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: LibreOffice
          Assignee: [email protected]
          Reporter: [email protected]

GalleryItem ( XGalleryItem ) wipes some of its properties as soon as it is
returned from a funciton.

This bug is found in Python

When a GalleryItem is passed from a function it looses Drawing, Graphic, etc,
properties.

Pseudo code for illustration

> import sys
> 
> def find_gallery_item(gallery_name: str, name: str) -> XGalleryItem:
>     gallery = get_gallery(gallery_name) # XGalleryTheme
>     num_pics = gallery.getCount()
> 
>     result = None
>     for i in range(num_pics):
>         item = gallery.getByIndex(i)
>         # run code to find item.
>         result = item
>         break
> 
>     # sys.getrefcount() adds a refcount so sys.getrefcount() - 1
>     # Reference count for result.Drawing is 0
>     print("result.Drawing ref count:", sys.getrefcount(result.Drawing) - 1)
>     # this means as soon as result is return from this function then 
>     #python garbage collector deletes result.Drawing
> 
>     # this next line report as expected. result.Drawing is XDrawing instance
>     report_gallery_item(result)
>     return result
> 
>     def report_gallery_item(item: XGalleryItem) -> None:
>         if item is None:
>             print("Gallery item is null")
>             return
> 
>         print("Gallery item information:")
>         url = str(mProps.Props.get(item, "URL"))
>         path = mFileIo.FileIO.uri_to_path(uri_fnm=url, ensure_absolute=False)
>         print(f'  URL: "{url}"')
>         print(f'  Fnm: "{Path(Gallery.gallery_dir, 
> mFileIo.FileIO.get_fnm(path))}"')
>         print(f"  Path: {path}")
> 
>         print(f'  Title: "{mProps.Props.get(item, "Title")}"')
>         item_int_type = int(mProps.Props.get(item, "GalleryItemType"))
>         print(f"  Type: 
> {cls.get_item_type_str(GalleryItemTypeEnum(item_int_type))}")
> 
> item = find_gallery_item(gallery_name="Shapes", name="Sun")
> 
> report_gallery_item(item) # at this point item.Drawing is None

I have documented this in some detail on Ask.
https://ask.libreoffice.org/t/libreoffice-wiping-object-properties-issue-with-gallerythemeprovider/83182

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to