Slow Recompile & Quick Dictionary

All flavors welcome.
Forum rules
Be kind.
Post Reply
TerryL
Posts: 74
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: 1687
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: 74
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: 1687
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 10 times
intersect-fixed.png
intersect-fixed.png (72 KiB) Viewed 177 times
I just have the dropped SQL connection issue on the mac to fix now.
TerryL
Posts: 74
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: 1687
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: 74
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: 1687
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 65 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 65 times
I can also verify that in the inspector:
c.png
c.png (285.92 KiB) Viewed 65 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 65 times
So, I'm a bit puzzled.
User avatar
tperry2x
Posts: 1687
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 49 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 49 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 47 times
Attachments
Quick Dictionary.livecode
(59.24 KiB) Downloaded 3 times
TerryL
Posts: 74
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
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests