octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #65318] Deprecation warning with C++20


From: John W. Eaton
Subject: [Octave-bug-tracker] [bug #65318] Deprecation warning with C++20
Date: Fri, 16 Feb 2024 04:42:29 -0500 (EST)

Follow-up Comment #8, bug#65318 (group octave):

"I might have misunderstood the comment about the lifetime of the captured
objects. But wouldn't we need to capture with `[*this]` to keep them?"

One example is the lambda function that is created in the
main_window::handle_edit_mfile_request function in the GUI to perform an
action in the interpreter.  I don't think we want to work with a copy of the
main_window object when we emit signals at the end of the lambda.  But we do
need copies of local variables containing the file and directory names.

Because it is possible that the main_window object has been deleted before the
lambda function executes in the interpreter thread, we use a QPointer object
to check that possibility and exit early if needed.  If we knew that the
main_window object would be valid for the entire lifetime of the program, then
we wouldn't need that check.  But it would still be wrong to capture other
local variables by reference because they certainly won't be live by the time
the lambda is executed.


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?65318>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]