Canvas Not Refreshing photos for upper version of OS-X

Using OSX 10.11
Canvas(ct).Refresh Works

But on upper OSX such as 10.13 HSeirra or 10.15( Catalina )
Canvas(ct).Refresh does not work.

does any one know why ?

and what is the difference between refresh and Invalidate ?

Please advise.

refresh asks the OS to update the view/control/canvas right away.

invalidate marks the view/control/canvas as needing to be redrawn on the next run loop, i.e. when the current thread is complete.

invalidate will also coalesce calls, so you can call invalidate as many times as you like in a function, but it gets updated only once, where as refresh does it for each and every time.

Modern macOS versions also use triple buffering, which means if you have a nested UI, and only call invalidate/refresh on a container view/control/canvas, only it’s contents gets updated, but not the children of the container. I’ve written code to handle this and it’s included as part of the Ohanaware App Kit, exclusive to this years http://omegabundle.net bundle.

Before i get into yet another bundle
i wanted to know if any one has a Xojo easy fix xojo.

[code]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

PhotoWin.Thumb(Ct).Refresh

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

End If

next Ct[/code]

Well, before we can help it would be good if you could explain what you mean with “doesn’t work”. Do some screenshots of the different versions of macOS.

In my experience in newer versions of macOS there is no difference between .invalidate and .refresh.

Hi,

“doesn’t work” meaning the canvas do not show the image(s) in more recent OSX Versions, using the above code with canvas.refresh

Please see example screen shots.

http://culser.com/photo/Screen_Shot_2020-07-13_at_7.48.49_AM.png
http://culser.com/photo/Screen_Shot_2020-07-13_at_8.12.29_AM.png

i would rewrite this code part.
sub class this thumbnail canvas and add a computed property where you set a picture property + use .invalidate.
in the paint event paint the picture property,
or set a folderitem and load the picture at first access there,

[quote=496189:@David Cullins]Hi,

“doesn’t work” meaning the canvas do not show the image(s) in more recent OSX Versions, using the above code with canvas.refresh

Please see example screen shots.

http://culser.com/photo/Screen_Shot_2020-07-13_at_7.48.49_AM.png
http://culser.com/photo/Screen_Shot_2020-07-13_at_8.12.29_AM.png[/quote]
I’m curious… on the systems where this is failing, was the drive formatted as Case-Sensitive? That would cause this if the paths aren’t exactly the same.

Greg

the Drive that is Using OSX 10.11 ( canvas update working )
is formmated in MAC OS Ext (Journaled)

The 10.15( Catalina ) system ( canvas update not working )
is formmated the same MAC OS Ext ( Journaled )

both drive have upper and lower case file and folder naming

The app uses the same naming convention for the folderitem(s) and files

The 10.11 drive was actually at one time formated as NT but recently changed to OS Ext Journaled and the canvas updating worked on both.

Marcus,

the canvas thumbs have no events, the events for all canvas thumbs are handled by another ThumbSet, please see a screen shot.
http://culser.com/photo/Screen_Shot_2020-07-13_at_9.26.21_AM.png

So could this be a permissions problem? Where does TumbsFolder get set, and how?

you should rethink/rewrite this source code in paint event screenshot.
you could make your life simpler if you u use a new class and set super to canvas, you can use propertys and methods then.
the paint event is not the place to open a picture file.
you should also avoid direct access to other windows.
use g.Width not Me.Width
status1.text = “loading” should not be there.
there is a possible return without draw anything.

Tim
the Thumbsfolder is set in an Open event when the app first launches

Markus
working on setting up a new class, might need help with this.

Marcus

In the new class there would be a method that opens a photo, and assigns it to the classes global Property “globalpicture” ?
globalpicture = picture.Open(f)

then the paint event uses this global propety ?

am i on the right track ?
http://culser.com/photo/CanvasClass.png

not - but Sharded Methods can also be useful.

each instance can hold her own data. i guess each thumbnail look different.

make a PicLocation As FolderItem Property and then convert it via Menu to Computed Property.
add a MyPicture Property As Picture and then convert it via Menu to Computed Property.

in the set of PicLocation use MyPicture = Picture.Open(value)

in the set of MyPicture use Me.Invalidate(False) that will cause a new paint

in the Paint Event use g.DrawPicture with MyPicture and at top use
if MyPicture = Nil then g.DrawText with a warning

From where? Are you asking the user for it via an OpenDialog? Or are you just assuming you can access somewhere? Because you can’t assume that as of Sierra (10.12). It could cause these issues, but you wouldn’t see it during debug.

Tim,
not from Dialog,
From a Text Field which is a settting that app remembers once entered by the User - ( siteLocation.Text )
dim df as FolderItem = New FolderItem(MainWin.SiteLocation.text, FolderItem.PathTypeShell)
if the folder path is wrong/mis-spelled/ i would get an exception. So far no exceptions.

Marcus
I’m working on it,
i am using a Shared Method within the New Canvas Class.

[quote=496261:@David Cullins]From a Text Field which is a settting that app remembers once entered by the User - ( siteLocation.Text )
dim df as FolderItem = New FolderItem(MainWin.SiteLocation.text, FolderItem.PathTypeShell)
if the folder path is wrong/mis-spelled/ i would get an exception. So far no exceptions.[/quote]
Oh this is definitely the problem.

tim

how do you recommend this be handled ( in code )

[quote=496264:@David Cullins]
how do you recommend this be handled ( in code )[/quote]
Conforming to Apple’s security requirements can be a bit of a challenge. If these are user provided photos, you should offer an OpenDialog to select them, and then copy them into your application data folder. You have access to SpecialFolder.Temporary and SpecialFolder.ApplicationData.Child(“com.your.bundle.identifier”) without needing special permission, so this is how you would be able to retain and restore the photos later.

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=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.[/quote]
Can you not embed them in the database? That way all the data is kept together and you don’t need to worry about Apple getting too protective over user files.