File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -174,10 +174,13 @@ QStringList Command::optionNames() const
174174#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
175175 optionNames.insert (nthOption, commasCount, optionName);
176176#else
177+ /* We need to save the index position because the nthOption iterator will be
178+ invalidated after an insertion. */
179+ const auto optionIdx = static_cast <int >(
180+ std::distance (optionNames.cbegin (), nthOption));
181+
177182 for (auto i = 0 ; i < commasCount ; ++i)
178- optionNames.insert (static_cast <int >(std::distance (optionNames.cbegin (),
179- nthOption)),
180- optionName);
183+ optionNames.insert (optionIdx, optionName);
181184#endif
182185 // Take into account also a newly inserted option names
183186 ++nthOptionIdx += static_cast <decltype (nthOptionIdx)>(commasCount);
You can’t perform that action at this time.
0 commit comments