In one of my more complicated and larger projects, I keep running into Access Violations at times when opening a TCombox.
In my code the list items change under certain circumstances - so I figured that would be the culprit.
Even disabling the control while changing the items list made it still crash.
Disabling all events still keeps it crashing and the debugger keeps point to a certain procedure in "
CocoaTextEdits".
procedure TCocoaReadOnlyComboBoxMenuDelegate.menu_willHighlightItem(
menu: NSMenu; item: NSMenuItem);
begin
if Assigned(_lastHightlightItem) then
_lastHightlightItem.view.setNeedsDisplay_( True );
_lastHightlightItem:= item;
end;
With the debugger stating that
_lastHightlightItem is not defined (of course very likely an incorrect statement due to the crash).
I've tried numerous little test projects to see if I can reproduce this, but cannot reproduce it in those little projects.
Doing all kinds of elimination steps in my project (assuming I did something wrong) didn't fix it either.
(I'm still under the impression that I made a mistake)
However, what did fix it is commenting out the first two lines in "
TCocoaReadOnlyComboBoxMenuDelegate" (note: the TComboBox is
not set to be
readonly - in case that is relevant), like so:
procedure TCocoaReadOnlyComboBoxMenuDelegate.menu_willHighlightItem(
menu: NSMenu; item: NSMenuItem);
begin
// if Assigned(_lastHightlightItem) then
// _lastHightlightItem.view.setNeedsDisplay_( True );
_lastHightlightItem:= item;
end;
I am confident that these two lines have a very legit purpose, so I created a few test projects to see what would break because of removing these 2 lines, and low and behold, everything I tested works just fine.
Now I'm quite confident that the dev who wrote this code, placed it there for a very valid reason.
Note: I'm aware that posting my code would be more helpful, ut it is such a large project that it would be hard for anyone to see where I may have made a mistake. On top of that: it would be my problem to figure out of course.
After digging through all my code most of the day now, I just wanted to make sure I'm not wasting my time.
So my question is: did I bump into a bug or no longer needed code in "
CocoaTextEdits"?