Canvas Not Refreshing photos for upper version of OS-X

This might be true if your app is Sandboxed but we’ve never had to copy any user pictures. We literally have thousands of users running different versions of macOS so if this had been a problem we would have known about it.

[quote=496301:@David Cullins]the app manages a database of products, each product has up to 8 photos.
are you saying if the user wants to view or change photos they should be copied to a permission safe folder and viewed from there ? that seems like a lot of trouble just to view photos.

and to mention the main photo ( or 1st photo ) displays using the same folderitems coding i provided prior.
example here http://culser.com/photo/Screen_Shot_2020-07-13_at_7.48.49_AM.png
just the thumbs are not showing.

and in this example:
http://culser.com/photo/ListBox.png
when the listbox item is selected the thumb on the right shows and updates, no issues, using the same folderitem(s) and coding[/quote]
If you can access the same files at other times then I don’t think it is related to permissions / security.

We use the canvas control a lot and we have never experienced these kinds of issues no matter what version of OS is being used. It could be related to the version of Xojo you are using or possibly the code that physically draws the thumbnail in the canvas.

I saw that you posted some code right at the start which works with folder items. However, I didn’t see anything that seems to link the FolderItem to a specific thumbnail canvas or the actual code that draws the thumbnail.

I assume that you are using the canvas paint event so have you confirmed that your paint event code is actually being called.

Hi Kevin,

I feel the same way, if it works in one case using FolderItems/permission ect … it should work in all cases, so the issue has to be something else.

The version of Xojo is 2019 1.1 - due to a lot of issues in the latest update of XoJo i will not go beyond 1.1 until the issues are fixed, and there were a lot of them.

The Thumbs are controlled by a thumb set. Each thumbnail has an index starting at (0) - (7). 7 being the last thumb or the eighth position. The code at the start of this discusion was code to refresh and show all thumbs that are found for a given record, and is executed on demand or when the thumbnail window first opens.
When the user wants to change an image, it can be dragged and dropped on any of the 8 thumbs generating a (n) index number, this is how i know which thumb it is. the thumb is then created (using imagemagic), renamed to that position ect … xxxxxxxx-03.jpg,
hence the 3rd thumb ( and 3rd image ) and saved in the data base, then the canvases are refreshed to show the latest change.
here is a screen shot of the thumbs and the thumbset. ThumbImage is global and the name of the current Thumbnail either by drag and drop or simply by clicking on one of the 8 thumbs, In the paint event, the image is a child added to the FolderItem, then the photo is opened, and drawn.

here is a screen shot of the layout and code.
http://culser.com/photo/thumbset.png

All of this works and has worked for nearly 2 years, the only issue is recently i bought newer macs which have the higher OSX, which they are not refreshing the thumbs for the eye to see, but all other operations are working as expected.

[quote=496448:@David Cullins]Hi Kevin,

I feel the same way, if it works in one case using FolderItems/permission ect … it should work in all cases, so the issue has to be something else.

The version of Xojo is 2019 1.1 - due to a lot of issues in the latest update of XoJo i will not go beyond 1.1 until the issues are fixed, and there were a lot of them.

The Thumbs are controlled by a thumb set. Each thumbnail has an index starting at (0) - (7). 7 being the last thumb or the eighth position. The code at the start of this discusion was code to refresh and show all thumbs that are found for a given record, and is executed on demand or when the thumbnail window first opens.
When the user wants to change an image, it can be dragged and dropped on any of the 8 thumbs generating a (n) index number, this is how i know which thumb it is. the thumb is then created (using imagemagic), renamed to that position ect … xxxxxxxx-03.jpg,
hence the 3rd thumb ( and 3rd image ) and saved in the data base, then the canvases are refreshed to show the latest change.
here is a screen shot of the thumbs and the thumbset. ThumbImage is global and the name of the current Thumbnail either by drag and drop or simply by clicking on one of the 8 thumbs, In the paint event, the image is a child added to the FolderItem, then the photo is opened, and drawn.

here is a screen shot of the layout and code.
http://culser.com/photo/thumbset.png

All of this works and has worked for nearly 2 years, the only issue is recently i bought newer macs which have the higher OSX, which they are not refreshing the thumbs for the eye to see, but all other operations are working as expected.[/quote]

  1. Have you confirmed the paint event is being called?
  2. If it is being called have you added logging at various places within the paint event to determine what gets called?

Yes i know paint is being called because the canvases get painted in OSX 10.11

No i have never tried logging for any app before. i will look in to it.

Thank you

[quote=496565:@David Cullins]Yes i know paint is being called because the canvases get painted in OSX 10.11

No i have never tried logging for any app before. i will look in to it.

Thank you[/quote]
Have you checked that the paint event gets called on 10.15?

yes i ran logging on OS X 10.15 and the paint event is firing as expected.
Still the thumbs do not show.
The main Image in the photo window loads, the thumbs still do not load
the thumb in the MainWn loads

Also i load the picture prior to the paint even, i then do a refresh which causes the paint event to be called.

I am stumped.

can you reproduce the problem in a stand-alone project?

@David Cullins – Please post the code that you have in the thumbnail canvas paint events? That may shed some light here too.

here is the paint event code of the thumbSet which acts as the paint event for all the thumbs ( see photo )
http://culser.com/photo/Screen_Shot_2020-07-13_at_9.26.21_AM.png

[code]dim f as FolderItem
dim p as Picture = masterThumb
Dim nW, nH as integer

if MainWin.SiteLocation.Text = “” then
Return
End if

//status1.text = "loading … " + ThumbImage

if ThumbImage <> “” then
f = MainWin.ThumbFolder.Child(ThumbImage)

if f = Nil or Not f.Exists Then
f = MainWin.ThumbFolder.Child("_fill_image.jpg")
end if

// p = OpenPicture(f)

if p <> Nil Then

LoggingWin.WriteToAppLog("IN Thumb:" + str(index) + " PAINT")

nW = 100
nH = 100

g.ForeColor= &c000000
g.DrawRect(0,0,g.width,g.height)
g.DrawPicture(p,0,0, nW ,nH ,0,0,p.Width,p.Height)

LoggingWin.WriteToAppLog("Finished Thumb:" + str(index) + " PAINT")

else
g.ForeColor = &c000000
g.DrawString(“cannot load image”, 0,0)
LoggingWin.WriteToAppLog("G2: drawing Graphic Failed Image: " + Str(index))
end if
end if
[/code]

Here is the Shared Method that loads all the thumbs / some vars are Global such as ThumbFolder

[code]Dim Ext As String
Dim Ct As Integer = 0
Dim cnt As Integer = 0
Dim Limit As Integer = 8
Dim ThumbPath As FolderItem
Dim PicturePath As FolderItem

Ext = “-01.jpg”
ThumbPath = MainWin.PictureFolder.Child(MainWin.ItemID + Ext)

//MainImage = MainWin.ItemID + Ext
//photoWin.MainImg.Refresh

for Ct=0 To Limit - 1

If ThumbPath <> Nil Then

Ext = "-" + Format(Ct+1, "00") + ".jpg"
ThumbImage = MainWin.ItemID + Ext

ThumbPath = MainWin.ThumbFolder.Child(ThumbImage)
PicturePath = MainWin.PictureFolder.Child(ThumbImage)

if Not ThumbPath.Exists and Not PicturePath.Exists Then
  ThumbPath = MainWin.ThumbFolder.Child("_fill_image.jpg")
else
  cnt = cnt + 1
End if

masterThumb = OpenPicture(ThumbPath)
PhotoWin.Thumb(Ct).Refresh

Else
ThumbPath = MainWin.ThumbFolder.Child("_fill_image.jpg")
PhotoWin.Thumb(Ct).Refresh
End If

next Ct

NOI = cnt
[/code]

Have you tried putting a breakpoint at the top of those methods and stepping through to make sure they’re doing what you think they’re doing?

I only ask because in the first snippet, you’ve commented out the line that actually opens the picture, so you’ll always get masterThumb.

i have not put in Break points.

the comment on the “picture” load is because i am no longer opening the picture in the Paint Event,
in stead the picture is now being opened prior to the Paint Event ( in the shared method )
I made this change because a previous member suggested that the Picture should not be opened inside the paint event.
but i kept the remark to remind me of what i was doing previously.

i do know that in OS X 10.11 this code has been working with no problems for over 1 year.
testing the code on later systems (10.14+) , only the thumbs do not load. The main photo loads with no problems.
Essentially the same coding is used, just in different events.

[quote=497183:@David Cullins]I made this change because a previous member suggested that the Picture should not be opened inside the paint event.
but i kept the remark to remind me of what i was doing previously.[/quote]
That is correct, the ONLY thing you should be doing is drawing in the Paint event. All logic code, including placement code should be moved out of the paint event. You may not notice this now, but as your application gets bigger and more complicated, you’ll want to improve draw times as controls get asked to paint a lot.

Ironically, under modern macOS systems, images are lazy loading by default (I can’t tell if Xojo uses options to force the image to load on Picture creation), which means that the OS might actually be loading image data at paint time :slight_smile: