<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="12" style="border: 1px #c9c399 solid; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
<tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="https://git.reviewboard.kde.org/r/120572/">https://git.reviewboard.kde.org/r/120572/</a>
</td>
</tr>
</table>
<br />
<table bgcolor="#e0e0e0" width="100%" cellpadding="12" style="border: 1px gray solid; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
<tr>
<td>
<h1 style="margin: 0; padding: 0; font-size: 10pt;">This change has been marked as submitted.</h1>
</td>
</tr>
</table>
<br />
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="12" style="border: 1px #888a85 solid; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
<tr>
<td>
<div>Review request for Calligra, Boudewijn Rempt and Thorsten Zachmann.</div>
<div>By Friedrich W. H. Kossebau.</div>
<p style="color: grey;"><i>Updated Oct. 15, 2014, 5:57 p.m.</i></p>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt;">Repository: </b>
calligra
</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">If you load a file into Stage from current master, you see a lot of "Unknown shapes" on the screen (possibly mapping to some question marks in your head). Seems the plugins for Text shapes and Vector shapes are not available. I tried to find an answer to those questionmarks, and here is my story:</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">In Stage these days the singleton KoToolRegistry is created before the KoShapeRegistry one. So the init() method of it starts to load all "Flake" plugins and create their respective plugin objects, of which the first is (for me) the Formula Shape. Its constructor now has</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;"><div class="codehilite" style="background: #f8f8f8"><pre style="line-height: 125%"> KoToolRegistry<span style="color: #666666">::</span>instance()<span style="color: #666666">-></span>add( <span style="color: #008000; font-weight: bold">new</span> KoFormulaToolFactory() );
<span style="color: #BC7A00">#ifndef _MSC_VER</span>
KoToolRegistry<span style="color: #666666">::</span>instance()<span style="color: #666666">-></span>add( <span style="color: #008000; font-weight: bold">new</span> KoM2MMLFormulaToolFactory());
<span style="color: #BC7A00">#endif</span>
KoShapeRegistry<span style="color: #666666">::</span>instance()<span style="color: #666666">-></span>add( <span style="color: #008000; font-weight: bold">new</span> KoFormulaShapeFactory() );
</pre></div>
</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">So first gets the KoToolRegistry instance (where we are still in the constructor code actually, doooh) and adds 1-2 factories there, and then... calls for the singleton of KoShapeRegistry. That one does not yet exist, so one is created and in its constructor, yes, goes to load Flake and Shape plugins. Just, when going for the Flake plugins, KoPluginLoader will no longer deliver any Flake plugins to KoShapeRegistry, because</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;"><div class="codehilite" style="background: #f8f8f8"><pre style="line-height: 125%"> <span style="color: #408080; font-style: italic">// Don't load the same plugins again</span>
<span style="color: #008000; font-weight: bold">if</span> (d<span style="color: #666666">-></span>loadedServiceTypes.contains(serviceType)) {
<span style="color: #008000; font-weight: bold">return</span>;
}
</pre></div>
</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">and in the still ongoing call from KoToolRegistry to <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">KoPluginLoader::instance()->load(...)</code> for Flakes the servicetype was registered as first step.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">So when KoShapeRegistry's init method comes to <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">insertFactory(factories[i]);</code> it will miss out all Flake plugins, because none yet could register themselves to KoShapeRegistry, as the first trying to reach the singleton of KoShapeRegistry blocked the loading of Flakes until that singleton was done. And when it is done, it has already tried to learn about the factories.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Somehow this all calls for a redesign. But for now the attached patch, which only loads Flakes in KoShapeRegistry's init, seems to work for me.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">By the commit log it seems like this duplication to KoShapeRegistry which also loads "Flake"s was there forever. So no idea if that is needed perhaps? But I could not see any problem on a quick testing of all apps.</p></pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>libs/flake/KoToolRegistry.cpp <span style="color: grey">(bbb9681)</span></li>
</ul>
<p><a href="https://git.reviewboard.kde.org/r/120572/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>