<table><tr><td style="">dfaure requested changes to this revision.<br />dfaure added inline comments.<br />This revision now requires changes to proceed.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D25664">View Revision</a></tr></table><br /><div><strong>INLINE COMMENTS</strong><div><div style="margin: 6px 0 12px 0;"><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D25664#inline-144718">View Inline</a><span style="color: #4b4d51; font-weight: bold;">KoDialog.cpp:161</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="n">QObject</span><span style="color: #aa2211">::</span><span class="n">connect</span><span class="p">(</span><span class="n">button</span><span class="p">,</span> <span class="bright"></span><span class="n"><span class="bright">SIGNAL</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="n">clicked<span class="bright"></span></span><span class="bright"></span><span class="p"><span class="bright">()),</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span style="color: #aa2211">&</span><span class="n">mButtonSignalMapper</span><span class="p">,</span> <span class="n">SLOT</span><span class="p">(</span><span class="n">map</span><span class="p">()));</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="n">QObject</span><span style="color: #aa2211">::</span><span class="n">connect</span><span class="p">(</span><span class="n">button</span><span class="p">,</span> <span class="bright"></span><span style="color: #aa2211"><span class="bright">&</span></span><span class="bright"></span><span class="n"><span class="bright">QPushButton</span></span><span class="bright"></span><span style="color: #aa2211"><span class="bright">::</span></span><span class="n">clicked<span class="bright"></span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span><span class="bright"> </span><span class="p"><span class="bright">[</span></span><span class="bright"></span><span style="color: #aa4000"><span class="bright">this</span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">&</span></span><span class="bright"></span><span class="n"><span class="bright">key</span></span><span class="bright"></span><span class="p"><span class="bright">]</span></span><span class="bright"> </span><span class="p"><span class="bright">{</span></span><span class="bright"> </span><span class="n"><span class="bright">q_ptr</span></span><span class="bright"></span><span style="color: #aa2211"><span class="bright">-></span></span><span class="bright"></span><span class="n"><span class="bright">slotButtonClicked</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">key</span></span><span class="bright"></span><span class="p"><span class="bright">);</span></span><span class="bright"> </span><span class="p"><span class="bright">});</span></span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">I bet this crashes at runtime.</p>
<p style="padding: 0; margin: 8px;">You're capturing the local variable <tt style="background: #ebebeb; font-size: 13px;">key</tt> by reference, so it will have gone out of scope by the time the lambda calls the slot. Remove the <tt style="background: #ebebeb; font-size: 13px;">&</tt> to make it a capture by value.</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D25664#inline-144707">View Inline</a><span style="color: #4b4d51; font-weight: bold;">KoFormulaTool.cpp:115</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; "> <span class="n">connect</span><span class="p">(</span><span class="n">m_formulaShape</span><span style="color: #aa2211">-></span><span class="n">formulaData</span><span class="p">(),</span> <span class="n">SIGNAL</span><span class="p">(</span><span class="n">dataChanged</span><span class="p">(</span><span class="n">FormulaCommand</span><span style="color: #aa2211">*</span><span class="p">,</span><span style="color: #aa4000">bool</span><span class="p">)),</span> <span style="color: #aa4000">this</span><span class="p">,</span> <span class="n">SLOT</span><span class="p">(</span><span class="n">updateCursor</span><span class="p">(</span><span class="n">FormulaCommand</span><span style="color: #aa2211">*</span><span class="p">,</span><span style="color: #aa4000">bool</span><span class="p">)));</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="bright"></span><span class="n"><span class="bright">connect</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">m_signalMapper</span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span><span class="bright"> </span><span class="n"><span class="bright">SIGNAL</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">mapped</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">QString</span></span><span class="bright"></span><span class="p"><span class="bright">)),</span></span><span class="bright"> </span><span style="color: #aa4000"><span class="bright">this</span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span><span class="bright"> </span><span class="n"><span class="bright">SLOT</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">insert</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">QString</span></span><span class="bright"></span><span class="p"><span class="bright">)));</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="bright"></span><span style="color: #aa4000"><span class="bright">for</span></span><span class="bright"> </span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span style="color: #aa4000"><span class="bright">const</span></span><span class="bright"> </span><span class="n"><span class="bright">TemplateAction</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">&</span></span><span class="bright"></span><span style="color: #a0a000"><span class="bright">templateAction</span></span><span class="bright"> </span><span class="p"><span class="bright">:</span></span><span class="bright"> </span><span class="n"><span class="bright">m_templateActions</span></span><span class="bright"></span><span class="p"><span class="bright">)</span></span><span class="bright"> </span><span class="p"><span class="bright">{</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="n">connect</span><span class="p">(</span><span class="n">templateAction</span><span class="p">.</span><span class="n">action</span><span class="p">,</span> <span style="color: #aa2211">&</span><span class="n">QAction</span><span style="color: #aa2211">::</span><span class="n">triggered</span><span class="p">,</span> <span class="p">[</span><span style="color: #aa4000">this</span><span class="p">,</span> <span style="color: #aa2211">&</span><span class="n">templateAction</span><span class="p">]</span> <span class="p">{</span> <span class="n">insert</span><span class="p">(</span><span class="n">templateAction</span><span class="p">.</span><span class="n">data</span><span class="p">);</span> <span class="p">});</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;"><tt style="background: #ebebeb; font-size: 13px;">qAsConst(m_templateActions)</tt> to avoid a detach</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D25664#inline-144708">View Inline</a><span style="color: #4b4d51; font-weight: bold;">KoFormulaTool.cpp:124</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; "><span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span style="color: #aa4000">for</span> <span class="p">(</span><span style="color: #aa4000">const</span> <span class="n">TemplateAction</span> <span style="color: #aa2211">&</span><span style="color: #a0a000">templateAction</span> <span class="p">:</span> <span class="n">m_templateActions</span><span class="p">)</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="n">disconnect</span><span class="p">(</span><span class="n">templateAction</span><span class="p">.</span><span class="n">action</span><span class="p">,</span> <span style="color: #aa2211">&</span><span class="n">QAction</span><span style="color: #aa2211">::</span><span class="n">triggered</span><span class="p">,</span> <span style="color: #aa4000">nullptr</span><span class="p">,</span> <span style="color: #aa4000">nullptr</span><span class="p">);</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">same here</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D25664#inline-144709">View Inline</a><span style="color: #4b4d51; font-weight: bold;">KoFormulaTool.cpp:134</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; "> <span style="color: #74777d">//TODO: is this save?</span>
</div><div style="padding: 0 8px; margin: 0 4px; "> <span style="color: #aa4000">delete</span> <span class="n">m_cursorList</span><span class="p">[</span><span style="color: #601200">0</span><span class="p">];</span>
</div><div style="padding: 0 8px; margin: 0 4px; "> <span class="n">m_cursorList</span><span class="p">.</span><span class="n">removeAt</span><span class="p">(</span><span style="color: #601200">0</span><span class="p">);</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">completely unrelated : this those two lines could be combined into <tt style="background: #ebebeb; font-size: 13px;">delete m_cursorList.takeAt(0);</tt>, and the comment removed.</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D25664#inline-144716">View Inline</a><span style="color: #4b4d51; font-weight: bold;">SpellCheckMenu.cpp:83</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; "> <span class="n">QAction</span> <span style="color: #aa2211">*</span><span class="n">action</span> <span style="color: #aa2211">=</span> <span style="color: #aa4000">new</span> <span class="n">QAction</span><span class="p">(</span><span class="n">suggestion</span><span class="p">,</span> <span class="n">m_suggestionsMenu</span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="n">connect</span><span class="p">(</span><span class="n">action</span><span class="p">,</span> <span class="bright"></span><span class="n"><span class="bright">SIGNAL</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="n">triggered<span class="bright"></span></span><span class="bright"></span><span class="p"><span class="bright">()),</span></span><span class="bright"> </span><span class="n"><span class="bright">m_</span>suggestion<span class="bright">sSignalMapper</span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span><span class="bright"> </span><span class="n"><span class="bright">SLOT</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">map</span></span><span class="bright"></span><span class="p"><span class="bright">())</span>);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="n">m_suggestionsSignalMapper</span><span style="color: #aa2211">-></span><span class="n">setMapping</span><span class="p">(</span><span class="n">action</span><span class="p">,</span> <span class="n">suggestion</span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="n">connect</span><span class="p">(</span><span class="n">action</span><span class="p">,</span> <span class="bright"></span><span style="color: #aa2211"><span class="bright">&</span></span><span class="bright"></span><span class="n"><span class="bright">QAction</span></span><span class="bright"></span><span style="color: #aa2211"><span class="bright">::</span></span><span class="n">triggered<span class="bright"></span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span><span class="bright"> </span><span class="p"><span class="bright">[</span></span><span class="bright"></span><span style="color: #aa4000"><span class="bright">this</span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">&</span></span><span class="n">suggestion<span class="bright"></span></span><span class="bright"></span><span class="p"><span class="bright">]</span></span><span class="bright"> </span><span class="p"><span class="bright">{</span></span><span class="bright"> </span><span class="n"><span class="bright">replaceWord</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">suggestion</span></span><span class="bright"></span><span class="p"><span class="bright">);</span></span><span class="bright"> </span><span class="p"><span class="bright">}</span>);</span>
</div><div style="padding: 0 8px; margin: 0 4px; "> <span class="n">m_suggestionsMenu</span><span style="color: #aa2211">-></span><span class="n">addAction</span><span class="p">(</span><span class="n">action</span><span class="p">);</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">You're capturing <tt style="background: #ebebeb; font-size: 13px;">suggestion</tt> by reference, and it's a reference itself.<br />
Are you 100% sure that this will point to the m_suggestions list and not to the local variable?</p>
<p style="padding: 0; margin: 8px;">OK I did some googling and found that C++11 was unclear about that, C++14 clarified it to be OK.</p>
<p style="padding: 0; margin: 8px;">Still, I would just make a copy, so the next reader doesn't have to spend time googling for edge cases ;)</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D25664#inline-144713">View Inline</a><span style="color: #4b4d51; font-weight: bold;">TextTool.cpp:192</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; "> <span class="n">QAction</span> <span style="color: #aa2211">*</span><span class="n">a</span> <span style="color: #aa2211">=</span> <span style="color: #aa4000">new</span> <span class="n">QAction</span><span class="p">(</span><span class="n">factory</span><span style="color: #aa2211">-></span><span class="n">title</span><span class="p">(),</span> <span style="color: #aa4000">this</span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="n">connect</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="bright"></span><span class="n"><span class="bright">SIGNAL</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="n">triggered<span class="bright"></span></span><span class="bright"></span><span class="p"><span class="bright">()),</span></span><span class="bright"> </span><span class="n"><span class="bright">signalMapper</span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span><span class="bright"> </span><span class="n"><span class="bright">SLOT</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">map</span></span><span class="bright"></span><span class="p"><span class="bright">())</span>);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="n">signalMapper</span><span style="color: #aa2211">-></span><span class="n">setMapping</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">factory</span><span style="color: #aa2211">-></span><span class="n">id</span><span class="p">());</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="n">connect</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="bright"></span><span style="color: #aa2211"><span class="bright">&</span></span><span class="bright"></span><span class="n"><span class="bright">QAction</span></span><span class="bright"></span><span style="color: #aa2211"><span class="bright">::</span></span><span class="n">triggered<span class="bright"></span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span><span class="bright"> </span><span class="p"><span class="bright">[</span></span><span class="bright"></span><span style="color: #aa4000"><span class="bright">this</span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">&</span></span><span class="bright"></span><span class="n"><span class="bright">factory</span></span><span class="bright"></span><span class="p"><span class="bright">]</span></span><span class="bright"> </span><span class="p"><span class="bright">{</span></span><span class="bright"> </span><span class="n"><span class="bright">startTextEditingPlugin</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">factory</span></span><span class="bright"></span><span style="color: #aa2211"><span class="bright">-></span></span><span class="bright"></span><span class="n"><span class="bright">id</span></span><span class="bright"></span><span class="p"><span class="bright">());</span></span><span class="bright"> </span><span class="p"><span class="bright">}</span>);</span>
</div><div style="padding: 0 8px; margin: 0 4px; "> <span class="n">list</span><span class="p">.</span><span class="n">append</span><span class="p">(</span><span class="n">a</span><span class="p">);</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Remove <tt style="background: #ebebeb; font-size: 13px;">&</tt> here too -- reference to local variable, used later = crash.</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D25664#inline-144719">View Inline</a><span style="color: #4b4d51; font-weight: bold;">SimpleCitationBibliographyWidget.cpp:80</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; "> <span class="n">preview</span><span style="color: #aa2211">-></span><span class="n">updatePreview</span><span class="p">(</span><span class="n">info</span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="n">connect</span><span class="p">(</span><span class="n">preview</span><span class="p">,</span> <span class="bright"></span><span class="n"><span class="bright">SIGNAL</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="n">pixmapGenerated<span class="bright"></span></span><span class="bright"></span><span class="p"><span class="bright">()),</span></span><span class="bright"> </span><span class="n"><span class="bright">m_signalMapper</span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span><span class="bright"> </span><span class="n"><span class="bright">SLOT</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">map</span></span><span class="bright"></span><span class="p"><span class="bright">())</span>);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="n">m_signalMapper</span><span style="color: #aa2211">-></span><span class="n">setMapping</span><span class="p">(</span><span class="n">preview</span><span class="p">,</span> <span class="n">index</span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="n">connect</span><span class="p">(</span><span class="n">preview</span><span class="p">,</span> <span class="bright"></span><span style="color: #aa2211"><span class="bright">&</span></span><span class="bright"></span><span class="n"><span class="bright">BibliographyPreview</span></span><span class="bright"></span><span style="color: #aa2211"><span class="bright">::</span></span><span class="n">pixmapGenerated<span class="bright"></span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span><span class="bright"> </span><span class="p"><span class="bright">[</span></span><span class="bright"></span><span style="color: #aa4000"><span class="bright">this</span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">&</span></span><span class="bright"></span><span class="n"><span class="bright">index</span></span><span class="bright"></span><span class="p"><span class="bright">]</span></span><span class="bright"> </span><span class="p"><span class="bright">{</span></span><span class="bright"> </span><span class="n"><span class="bright">pixmapReady</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">index</span></span><span class="bright"></span><span class="p"><span class="bright">);</span></span><span class="bright"> </span><span class="p"><span class="bright">}</span>);</span>
</div><div style="padding: 0 8px; margin: 0 4px; "> <span class="n">m_previewGenerator</span><span class="p">.</span><span class="n">append</span><span class="p">(</span><span class="n">preview</span><span class="p">);</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">you know what I'm going to say ;)</p>
<p style="padding: 0; margin: 8px;">+ add <tt style="background: #ebebeb; font-size: 13px;">this</tt> as 3rd argument</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D25664#inline-144721">View Inline</a><span style="color: #4b4d51; font-weight: bold;">SimpleCitationBibliographyWidget.cpp:110</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; "> <span class="n">widget</span><span class="p">.</span><span class="n">addBibliography</span><span style="color: #aa2211">-></span><span class="n">addItem</span><span class="p">(</span><span class="n">m_chooser</span><span class="p">,</span> <span class="n">m_previewGenerator</span><span class="p">.</span><span class="n">at</span><span class="p">(</span><span class="n">templateId</span><span class="p">)</span><span style="color: #aa2211">-></span><span class="n">previewPixmap</span><span class="p">(),</span> <span class="n">templateId</span> <span style="color: #aa2211">+</span> <span style="color: #601200">1</span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="n">disconnect</span><span class="p">(</span><span class="n">m_previewGenerator</span><span class="p">.</span><span class="n">at</span><span class="p">(</span><span class="n">templateId</span><span class="p">),</span> <span class="bright"></span><span class="n"><span class="bright">SIGNAL</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="n">pixmapGenerated<span class="bright"></span></span><span class="bright"></span><span class="p"><span class="bright">()),</span></span><span class="bright"> </span><span class="n"><span class="bright">m_signalMapper</span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span><span class="bright"> </span><span class="n"><span class="bright">SLOT</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">map</span></span><span class="bright"></span><span class="p"><span class="bright">())</span>);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="n">disconnect</span><span class="p">(</span><span class="n">m_previewGenerator</span><span class="p">.</span><span class="n">at</span><span class="p">(</span><span class="n">templateId</span><span class="p">),</span> <span class="bright"></span><span style="color: #aa2211"><span class="bright">&</span></span><span class="bright"></span><span class="n"><span class="bright">BibliographyPreview</span></span><span class="bright"></span><span style="color: #aa2211"><span class="bright">::</span></span><span class="n">pixmapGenerated<span class="bright"></span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span><span class="bright"> </span><span style="color: #aa4000"><span class="bright">nullptr</span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span><span class="bright"> </span><span style="color: #aa4000"><span class="bright">nullptr</span></span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; "> <span class="n">m_previewGenerator</span><span class="p">.</span><span class="n">at</span><span class="p">(</span><span class="n">templateId</span><span class="p">)</span><span style="color: #aa2211">-></span><span class="n">deleteLater</span><span class="p">();</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">This is a bit dangerous, it also disconnects any other possible receiver. You should be able to pass <tt style="background: #ebebeb; font-size: 13px;">this</tt> as 3rd arg instead of <tt style="background: #ebebeb; font-size: 13px;">nullptr</tt>, if you pass <tt style="background: #ebebeb; font-size: 13px;">this</tt> at connect time too.</p>
<p style="padding: 0; margin: 8px;">(this applies to all the disconnects in this change request)</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D25664#inline-144720">View Inline</a><span style="color: #4b4d51; font-weight: bold;">SimpleTableOfContentsWidget.cpp:78</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; "> <span class="n">preview</span><span style="color: #aa2211">-></span><span class="n">updatePreview</span><span class="p">(</span><span class="n">info</span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="n">connect</span><span class="p">(</span><span class="n">preview</span><span class="p">,</span> <span class="bright"></span><span class="n"><span class="bright">SIGNAL</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="n">pixmapGenerated<span class="bright"></span></span><span class="bright"></span><span class="p"><span class="bright">()),</span></span><span class="bright"> </span><span class="n"><span class="bright">m_signalMapper</span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span><span class="bright"> </span><span class="n"><span class="bright">SLOT</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">map</span></span><span class="bright"></span><span class="p"><span class="bright">())</span>);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="n">m_signalMapper</span><span style="color: #aa2211">-></span><span class="n">setMapping</span><span class="p">(</span><span class="n">preview</span><span class="p">,</span> <span class="n">index</span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="n">connect</span><span class="p">(</span><span class="n">preview</span><span class="p">,</span> <span class="bright"></span><span style="color: #aa2211"><span class="bright">&</span></span><span class="bright"></span><span class="n"><span class="bright">TableOfContentsPreview</span></span><span class="bright"></span><span style="color: #aa2211"><span class="bright">::</span></span><span class="n">pixmapGenerated<span class="bright"></span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span><span class="bright"> </span><span class="p"><span class="bright">[</span></span><span class="bright"></span><span style="color: #aa4000"><span class="bright">this</span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">&</span></span><span class="bright"></span><span class="n"><span class="bright">index</span></span><span class="bright"></span><span class="p"><span class="bright">]</span></span><span class="bright"> </span><span class="p"><span class="bright">{</span></span><span class="bright"> </span><span class="n"><span class="bright">pixmapReady</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">index</span></span><span class="bright"></span><span class="p"><span class="bright">);</span></span><span class="bright"> </span><span class="p"><span class="bright">}</span>);</span>
</div><div style="padding: 0 8px; margin: 0 4px; "> <span class="n">m_previewGenerator</span><span class="p">.</span><span class="n">append</span><span class="p">(</span><span class="n">preview</span><span class="p">);</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">same</p>
<p style="padding: 0; margin: 8px;">Also, add <tt style="background: #ebebeb; font-size: 13px;">this</tt> as third argument.</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D25664#inline-144722">View Inline</a><span style="color: #4b4d51; font-weight: bold;">Tool.h:69</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; "> <span style="color: #aa4000">for</span> <span class="p">(</span><span class="n">QHash</span><span style="color: #aa2211"><</span><span class="n">QString</span><span class="p">,</span> <span class="n">QAction</span><span style="color: #aa2211">*>::</span><span class="n">const_iterator</span> <span class="n">it</span> <span style="color: #aa2211">=</span> <span class="n">actionhash</span><span class="p">.</span><span class="n">constBegin</span><span class="p">();</span> <span class="n">it</span> <span style="color: #aa2211">!=</span> <span class="n">actionhash</span><span class="p">.</span><span class="n">constEnd</span><span class="p">();</span> <span style="color: #aa2211">++</span><span class="n">it</span><span class="p">)</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="n">connect</span><span class="p">(</span><span class="n">it</span><span class="p">.</span><span class="n">value</span><span class="p">(),</span> <span class="bright"></span><span class="n"><span class="bright">SIGNAL</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="n">triggered<span class="bright"></span></span><span class="bright"></span><span class="p"><span class="bright">()),</span></span><span class="bright"> </span><span class="n"><span class="bright">m_signalMapper</span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span><span class="bright"> </span><span class="n"><span class="bright">SLOT</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">map</span></span><span class="bright"></span><span class="p"><span class="bright">())</span>);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="n">m_signalMapper</span><span style="color: #aa2211">-></span><span class="n">setMapping</span><span class="p">(</span><span class="n">it</span><span class="p">.</span><span class="n">value</span><span class="p">()</span> <span class="p">,</span> <span class="n">it</span><span class="p">.</span><span class="n">key</span><span class="p">());</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="n">connect</span><span class="p">(</span><span class="n">it</span><span class="p">.</span><span class="n">value</span><span class="p">(),</span> <span class="bright"></span><span style="color: #aa2211"><span class="bright">&</span></span><span class="bright"></span><span class="n"><span class="bright">QAction</span></span><span class="bright"></span><span style="color: #aa2211"><span class="bright">::</span></span><span class="n">triggered<span class="bright"></span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span><span class="bright"> </span><span class="p"><span class="bright">[</span></span><span class="bright"></span><span class="n"><span class="bright">this</span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">&</span></span><span class="bright"></span><span class="n"><span class="bright">it</span></span><span class="bright"></span><span class="p"><span class="bright">]</span></span><span class="bright"> </span><span class="p"><span class="bright">{</span></span><span class="bright"> </span><span class="n"><span class="bright">actionTriggered</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">it</span></span><span class="bright"></span><span class="p"><span class="bright">.</span></span><span class="bright"></span><span class="n"><span class="bright">key</span></span><span class="bright"></span><span class="p"><span class="bright">());</span></span><span class="bright"> </span><span class="p"><span class="bright">}</span>);</span>
</div><div style="padding: 0 8px; margin: 0 4px; "> <span class="p">}</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="n">connect</span><span class="p">(</span><span class="n">m_signalMapper</span><span class="p">,</span> <span class="n">SIGNAL</span><span class="p">(</span><span class="n">mapped</span><span class="p">(</span><span class="n">QString</span><span class="p">)),</span> <span class="n">this</span><span class="p">,</span> <span class="n">SIGNAL</span><span class="p">(</span><span class="n">actionTriggered</span><span class="p">(</span><span class="n">QString</span><span class="p">)));</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Better capture a local variable called <tt style="background: #ebebeb; font-size: 13px;">key</tt> by value.</p>
<p style="padding: 0; margin: 8px;">Iterators get invalidated when containers change.</p></div></div></div></div></div><br /><div><strong>REPOSITORY</strong><div><div>R8 Calligra</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D25664">https://phabricator.kde.org/D25664</a></div></div><br /><div><strong>To: </strong>ognarb, Calligra: 3.0, KF6, dfaure<br /><strong>Cc: </strong>dfaure, Calligra-Devel-list, davidllewellynjones, dcaliste, ognarb, cochise, vandenoever<br /></div>