Slow Recompile & Quick Dictionary

All flavors welcome.
Forum rules
Be kind.
Post Reply
TerryL
Posts: 83
Joined: Sat Oct 16, 2021 5:05 pm
Contact:

Slow Recompile & Quick Dictionary

Post by TerryL »

o Slow Recompiled Windows 9.7
Anyone care to speculate on the slowness of the recompiled Windows 9.7 source? I made a google search for 'memory leak in C++', and came across these two interesting articles. I recall XCode (Mac) complained of memory leaks while trying to recompile 9.7, maybe Visual Studio (Win) isn't as sensitive during a compile? According to the first article by Microsoft, Visual Studio comes with tools for detecting such things, and there are 3rd party software tools as well (one open source). I realize finding and fixing are two very different things, and I don't pretend to understand any of it.
https://learn.microsoft.com/en-us/cpp/c ... w=msvc-170
https://favtutor.com/blogs/memory-leaks-cpp

"Memory leaks are among the most subtle and hard-to-detect bugs in C/C++ apps. Memory leaks result from the failure to correctly deallocate memory that was previously allocated. A small memory leak might not be noticed at first, but over time can cause symptoms ranging from poor performance to crashing when the app runs out of memory. A leaking app that uses up all available memory can cause other apps to crash, creating confusion as to which app is responsible. Even harmless memory leaks might indicate other problems that should be corrected. The Visual Studio debugger and C Run-Time Library (CRT) can help you detect and identify memory leaks."

o Quick Dictionary Problem
I came across a search problem with Quick Dictionary. Search on 'intersect'. There is an 'intersect' command, function, and keyword. Click on the function or keyword and the command data is displayed. It's hitting on the first 'intersect' in the database, not the intended 'intersect'. The original Dictionary doesn't have this problem. No idea how to fix.
User avatar
tperry2x
Posts: 1841
Joined: Tue Dec 21, 2021 9:10 pm
Location: Britain (Previously known as Great Britain)
Contact:

Re: Slow Recompile & Quick Dictionary

Post by tperry2x »

I can confirm, searching for intersect seems to confuse the dictionary. Unfortunately to both of these points above, I don't know how to fix either of them. :?
TerryL
Posts: 83
Joined: Sat Oct 16, 2021 5:05 pm
Contact:

Re: Slow Recompile & Quick Dictionary

Post by TerryL »

@ tperry. I think I fixed the Quick Dictionary problem, please verify. It was searching only for 'entry_name'. I added 'entry_type' to the tSQL search and now it seems to work as expected on Windows.

Quick Dictionary fix for confusing same-name/different-type database entries:
1) Edit the script of grp "Risultati" --in msg box
2) Make these changes to lines 1 - 6 of grp "Risultati" (tType added to search)
on selectionChanged pHilitedIndex, pPrevHilitedIndex
local tSelDataA, tName, tType, tID, tSQL, tRecordSet, tError, temp2, temp3, temp4, tSubArray
put the dgDataOfIndex[pHilitedIndex] of me into tSelDataA
put textDecode(tSelDataA["Col 1"] ) into tName
put textDecode(tSelDataA["Col 2"] ) into tType
put the cConnID of this card into tID --custom property
put "SELECT entry_data FROM dictionary_data WHERE entry_name='"& tName &"' AND entry_type='"& tType &"' ;" into tSQL
----
User avatar
tperry2x
Posts: 1841
Joined: Tue Dec 21, 2021 9:10 pm
Location: Britain (Previously known as Great Britain)
Contact:

Re: Slow Recompile & Quick Dictionary

Post by tperry2x »

Sorry, only just seen this post from Thursday.
TerryL wrote: Thu May 09, 2024 4:39 pm @ tperry. I think I fixed the Quick Dictionary problem, please verify
Indeed you have. Brilliant :D thank you.
Worked like a charm, so I attach it here for a drop in replacement in the plugins folder.
Quick Dictionary.livecode
(59.09 KiB) Downloaded 56 times
intersect-fixed.png
intersect-fixed.png (72 KiB) Viewed 779 times
I just have the dropped SQL connection issue on the mac to fix now.
TerryL
Posts: 83
Joined: Sat Oct 16, 2021 5:05 pm
Contact:

Re: Slow Recompile & Quick Dictionary

Post by TerryL »

@ tPerry, RE Quick Dictionary Error On Mac.
To check if a mac-sqlite problem, try mac LCC 9.6.3 original dictionary.

If that works as expected then seems like a mac-QDict problem. If so, I'll take a look at fld "Cerca2".

I wonder if this is an SQLite version problem fixed with an LC update, as MacOS is such a moving target (OXT Lite is SQLite v3.34?) I did an LC bug search on 'Dictionary' and didn't find anything relevant, though you might want to look at it for dictionary database update ideas, <https://quality.livecode.com/>. The latest version is SQLite v3.46.0, <https://www.sqlite.org/draft/index.html>.
----
User avatar
tperry2x
Posts: 1841
Joined: Tue Dec 21, 2021 9:10 pm
Location: Britain (Previously known as Great Britain)
Contact:

Re: Slow Recompile & Quick Dictionary

Post by tperry2x »

TerryL wrote: Tue May 14, 2024 6:48 pm @ tPerry, RE Quick Dictionary Error On Mac.
To check if a mac-sqlite problem, try mac LCC 9.6.3 original dictionary.
Ah, okay - you mean swap in the LCC dictionary to see if that gives an error. That's a good point. I'll give that a go.
Paul also suggested somewhere that it might be related to a path issue, but we were not sure. I'll try that tomorrow or before the end of the week certainly.
TerryL
Posts: 83
Joined: Sat Oct 16, 2021 5:05 pm
Contact:

Re: Slow Recompile & Quick Dictionary

Post by TerryL »

RE Mac-QDict invalid connection id error.

Code: Select all

on openCard  --in cd script of Quick Dictionary
   local tPath
   put specialFolderPath("engine") &"/Documentation/html_viewer/resources/data/api/api.sqlite" into tPath
   set the cConnID of me to revOpenDatabase("sqlite",tPath)  --sqlite db connection id > custom prop
   choose browse tool  --run mode arrow
   if the visible of fld "Cerca" then select text of fld "Cerca"  --insert cursor
   else select text of fld "Cerca2"  --insert cursor
   pass openCard
end openCard
- I ran many combinations of QDict open/close with/without the LCC original dictionary: no errors on windows. Above is the file path. If that was the problem on Mac, then SQLite would always throw the 'Cerca2 invalid id' error. The dictionary says specialFolderPath("engine") is good for Mac, Win, and Linux. Is the api.sqlite database in a different folder on Mac?

I have an idea. The problem may be with loading 'the cConnID of me' on openCard, the custom prop that holds the connection id.
When a database is first opened, SQLite creates a positive interger as a connection id. SQLite throws an error if a query is made without that number. When QDict is closed and re-opened, SQLite generates a new connection id and cConnID is set to that new id, overwriting the previous id.

Q. Does SQLite throw the 'Cerca2 invalid id' error on the first opening of QDict, on subsequent openings, only after a query, or seemingly random?
Try this:
1) Open QDict. In msg box: put the cConnID of this cd --(always "1" for me on windows)
2) Close QDict, re-Open QDict. Check the cConnID again. It SHOULD be a different integer. (I got 1,13,17, and another session 1,2,3)

Q. If you can generate an error, check the cConnID. Close QDict, re-open QDict, and check again. Is it a different integer?
- Crazy idea: maybe change 'set the cConnID of me' to 'set the cConnID of this card' in the openCard and closeStack handlers?
----
User avatar
tperry2x
Posts: 1841
Joined: Tue Dec 21, 2021 9:10 pm
Location: Britain (Previously known as Great Britain)
Contact:

Re: Slow Recompile & Quick Dictionary

Post by tperry2x »

TerryL wrote: Thu May 16, 2024 10:13 pm Q. Does SQLite throw the 'Cerca2 invalid id' error on the first opening of QDict, on subsequent openings, only after a query, or seemingly random?
Try this:
1) Open QDict. In msg box: put the cConnID of this cd --(always "1" for me on windows)
2) Close QDict, re-Open QDict. Check the cConnID again. It SHOULD be a different integer. (I got 1,13,17, and another session 1,2,3)

Q. If you can generate an error, check the cConnID. Close QDict, re-open QDict, and check again. Is it a different integer?
- Crazy idea: maybe change 'set the cConnID of me' to 'set the cConnID of this card' in the openCard and closeStack handlers?
----
The error occurs as soon as you trigger a search in the "Cerca2" field:
a.png
a.png (336.78 KiB) Viewed 667 times
It's not random - which maybe is a good thing?, it's every time the database is queried as far as I can tell.
I never get as far as getting a connection ID. Running this in the message box gives this error on MacOS:
b.png
b.png (295.72 KiB) Viewed 667 times
I can also verify that in the inspector:
c.png
c.png (285.92 KiB) Viewed 667 times
I changed all mentions of "set the cConnID of me" to "set the cConnID of this card', but I still get the error:
d.png
d.png (325.16 KiB) Viewed 667 times
So, I'm a bit puzzled.
User avatar
tperry2x
Posts: 1841
Joined: Tue Dec 21, 2021 9:10 pm
Location: Britain (Previously known as Great Britain)
Contact:

Re: Slow Recompile & Quick Dictionary

Post by tperry2x »

Aha, got it.
So - getting the engine path is a little different on MacOS compared to Linux and Windows.

On Linux and Windows, the engine path will return the path that the executable is in. Due to the way MacOS applications are structured, getting the engine path on the Mac returns the path containing the "unix executable" code, not where the .app is located - you have to regress up one folder, then look in the "Tools" folder. This is indeed a path issue and is fixed with:
fixed.png
fixed.png (48.93 KiB) Viewed 651 times
The one-liner fix in this screenshot is commented -- allowances for MacOS. (I should have spotted this sooner to be fair, but it only occurred to me while driving home this evening).

This is what I mean. Getting the engine path is actually getting this folder, when you want what's inside the 'Tools' folder (Specific to MacOS)
Screenshot 2024-05-17 at 19.26.33.png
Screenshot 2024-05-17 at 19.26.33.png (89.47 KiB) Viewed 651 times
Now, before anyone mentions it. Yes, I know it says "Livecode-Community" in the screenshot above. I can't really change that until I can recompile the Mac engine, and I'm aware that it needs changing. This is done in xCode ideally. (Renaming will break codesigning and probably a lot more).

Anyway, I digress.
Fixed (yay!)
quick-dictionary-fixed.png
quick-dictionary-fixed.png (78.83 KiB) Viewed 649 times
Attachments
Quick Dictionary.livecode
(59.24 KiB) Downloaded 53 times
TerryL
Posts: 83
Joined: Sat Oct 16, 2021 5:05 pm
Contact:

Re: Slow Recompile & Quick Dictionary

Post by TerryL »

Excellent, well done. The specialfolderpath dictionary entry probably needs an edit about "engine" then too. Terry
TerryL
Posts: 83
Joined: Sat Oct 16, 2021 5:05 pm
Contact:

Re: Slow Recompile & Quick Dictionary

Post by TerryL »

@ tPerry. You're not given enough credit for the clever improvements and modifications you've made to OXT Lite.
I noticed four things in Quick Dictionary.
-1- The two search styles.
Fld "Cerca2" was regular search, (where you enter a term and hit returnKey), but it's now subtractive.
Fld "Cerca" was subtractive (where you check the checkbox), but it doesn't do anything, even with returnKey.
Maybe you wanted to switch them and overlooked the checkbox? If you wanted just subtractive search, you could hide the checkbox (rather than deleting).
-2- While it doesn't hurt, probably don't need the try/catch error routine anymore.
-3- Did you intend the label to be partial-capitals? ('Quick Reference Dictionary' instead of 'Quick reference xTalk Dictionary')
-4- Group "Risultati" looks kind of strange without a border. Maybe this was on purpose for dark-mode?
Anyway, no digs intended, just observations, no need to justify.

It's unfortunate the Mac and Windows recompile didn't turn out, especially considering the effort made to get the pre-built binaries. I doubt someone with the skill-set will magically appear. No one has forwarded a solution.

Did you see my text-to-speech lesson 1 for YouTube video?
viewtopic.php?p=8707#p8707
Since no one wants a video with their own voice, text-to-speech was suggested. There should be a vote whether a video made is worthy before YouTube upload. And thanks for the tab panel buttons image. Terry
User avatar
tperry2x
Posts: 1841
Joined: Tue Dec 21, 2021 9:10 pm
Location: Britain (Previously known as Great Britain)
Contact:

Re: Slow Recompile & Quick Dictionary

Post by tperry2x »

Hi Terry.
These are all very valid comments. I've made a few changes. I'll address these points in order (just so I don't forget to cover something).
TerryL wrote: Sat May 18, 2024 7:17 pm @ tPerry. You're not given enough credit for the clever improvements and modifications you've made to OXT Lite.
Well, I hope people can see I'm trying to improve things. Yes, I may stumble along the way but I guess it's in an ever-evolving state. Thank you though.
TerryL wrote: Sat May 18, 2024 7:17 pm I noticed four things in Quick Dictionary.
-1- The two search styles.
Fld "Cerca2" was regular search, (where you enter a term and hit returnKey), but it's now subtractive.
Fld "Cerca" was subtractive (where you check the checkbox), but it doesn't do anything, even with returnKey.
Maybe you wanted to switch them and overlooked the checkbox? If you wanted just subtractive search, you could hide the checkbox (rather than deleting).
I've just had a go at that, but I don't know enough about SQL queries - so I've just hidden the 'sub' button as you suggest, and left the search how it is as it works. I dare not touch it for fear of breaking it too much. I didn't make the original stack this is based on, but it's adapted from someone else's work - so I'm standing on someone else's shoulders here. (not sure of original author) :|
TerryL wrote: Sat May 18, 2024 7:17 pm -2- While it doesn't hurt, probably don't need the try/catch error routine anymore.
The try/catch was the most graceful way I could handle closing the database. If it was already closed (by a timeout error I'd assume), then it would throw a script error if trying to close a second time (I suppose you can't close something that isn't open, so makes sense). The try/catch was the easiest & most reliable method I found as I couldn't find any reliable example to check if a database is in it's open state or closed state.
TerryL wrote: Sat May 18, 2024 7:17 pm -3- Did you intend the label to be partial-capitals? ('Quick Reference Dictionary' instead of 'Quick reference xTalk Dictionary')
That's a very good point. I've renamed to "Quick reference xTalk dictionary". (All lowercase except for the first word, and the 'T' in xTalk as that seems to be what we've used elsewhere, so it at least matches now.
TerryL wrote: Sat May 18, 2024 7:17 pm -4- Group "Risultati" looks kind of strange without a border. Maybe this was on purpose for dark-mode?
Anyway, no digs intended, just observations, no need to justify.
I don't see any of that as a dig. How you phrased your post, it all comes across as genuine feedback :D
Regarding the border: I know what you mean, but if I put the border back on, weird stuff happens:
border-no-no.png
border-no-no.png (21.31 KiB) Viewed 572 times
So I've just left the border off.
revised.png
revised.png (72.36 KiB) Viewed 572 times
TerryL wrote: Sat May 18, 2024 7:17 pm It's unfortunate the Mac and Windows recompile didn't turn out, especially considering the effort made to get the pre-built binaries. I doubt someone with the skill-set will magically appear. No one has forwarded a solution.
Yes, but at least we have what we need I think now. Seemingly someone with a more developed C++ skillset will be able to take that further, I'm sure.
TerryL wrote: Sat May 18, 2024 7:17 pm Did you see my text-to-speech lesson 1 for YouTube video?
viewtopic.php?p=8707#p8707

There should be a vote whether a video made is worthy before YouTube upload.
I'd not looked at that yet, but I will do - I'm currently weighing up exactly what to make the videos about. Do I start from the absolute basics, and work up from there? I agree that anything we / I make should probably be uploaded as a private video. Then if approved, you can always go back in and make it public.

One point though: It would be a very annoying (okay, probably hugely annoying) to go to the time and trouble of putting videos together, only to have them not 'pass muster' here first.

I propose we do something like a 'storyboard' view of what youtube content we cover, with a transcript of what we are going to say (would be helpful in planning the video, and when it actually comes to producing it too). That way, any amendments can be made without having to re-capture various bits and re-encoding / re-uploading the whole thing again.
Attachments
Quick Dictionary.livecode
(59.82 KiB) Downloaded 44 times
TerryL
Posts: 83
Joined: Sat Oct 16, 2021 5:05 pm
Contact:

Re: Slow Recompile & Quick Dictionary

Post by TerryL »

MaxV wrote the brilliant original, hence the Italian object names. I cleaned up a lot of the code and visual appearance, and added some code, though I could not have written it from scratch. I liked it because it was light and so darn fast. I emailed I'd added improvements, he responded too busy to look at. You're #2 to modify.

See if the attached version addresses the border 'weirdness'. It might have been because of different font sizes on different platforms. (I widened the second column to accomodate, then resized the data grid table). Works on Windows. Let me know if that fixed it on Mac/Linux? And the title, I didn't explain very well the first time, the current title is what I was suggesting. Use or not. Hope that helps. Terry
Attachments
QDictionary.zip
(24.87 KiB) Downloaded 46 times
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest