Questions regarding compiler warnings
Stephan Witt
st.witt at gmx.net
Wed Feb 12 20:17:13 UTC 2020
Am 12.02.2020 um 20:53 schrieb Jean-Marc Lasgouttes <lasgouttes at lyx.org>:
>
> Le 12/02/2020 à 20:45, Stephan Witt a écrit :
>> Hi all,
>> I've recently upgraded some parts of my tool box. I’m seeing new warnings now.
>> 1. deprecated warning (removed with C++17?)
>> lyx/src/insets/InsetCommandParams.cpp:596:9: warning: 'mem_fun_ref<bool, lyx::ParamInfo::ParamData>' is deprecated
>
> I already answered this one :)
Yes, I’ve noticed it :)
I don’t know what I’m talking about either. But,
perhaps std::mem_fn is a possible replacement?
https://en.cppreference.com/w/cpp/utility/functional/mem_fn
>> 2. various memory leak warnings
>> E.g. in GuiDocument::updateAvailableModules() - src/frontends/qt/GuiDocument.cpp, line 4474
>> There is an allocation here:
>> QStandardItem * catItem = new QStandardItem();
>> and later an assignment here:
>> catItem = fcats.first();
>> See the attached nice picture…
>> Should this be changed with the attached patch?
>
> The patch looks good to me.
Thanks, I’ll apply it then.
>> Similar problems are reported
>> - in GuiLyXFiles::updateContents() with
>> + QTreeWidgetItem * catItem - line 421
>> + QTreeWidgetItem * subcatItem - line 447
>> - in GuiToolbar::add() with
>> + InsertTableWidget * iv - line 495 (here I’m not sure)
>> 3. NULL pointer usage
>> In GuiView::dispatchVC are different buffer pointer variables used.
>> Sometimes there is an explicit check for NULL value.
>> Sometimes there is an assertion with break or return for release builds.
>> This looks inconsistent.
>
> This is inconsistent indeed.
>
>> 4. using uninitialized variable
>> In GuiCompleter::asyncUpdatePopup the x and y position are declared w/o initial value.
>> The virtual Inset::completionPosAndDim() method body is empty for common case.
>> Only InsetText, InsetTabular, InsetMathMacro and InsetMathNest have an assignment.
>> For all other insets (I didn't check if this is possible) the QRect results in garbage.
>
> Are these the insets that support completion? This is tested above, then. You can set position to 0 in order to please the compiler, I guess.
That’s the question indeed. And this is what I didn’t check.
To avoid potential pitfalls the assignment of 0 is the save way.
Stephan
More information about the lyx-devel
mailing list