Kate crash on exit - windows only?

Christian Ehrlicher Ch.Ehrlicher at gmx.de
Sun Mar 2 16:09:42 GMT 2008


Matthias Kretz schrieb:
> On Saturday 01 March 2008, Christian Ehrlicher wrote:
>> kdelibs_kate.patch
>>   Index: interfaces/ktexteditor/ktexteditor.cpp
>> ===================================================================
>> --- interfaces/ktexteditor/ktexteditor.cpp      (revision 780993)
>> +++ interfaces/ktexteditor/ktexteditor.cpp      (working copy)
>> @@ -188,14 +188,28 @@
>>    return KService::createInstance<KTextEditor::Plugin>(service, parent);
>>  }
>>  
>> +static QList<KPluginFactory*> s_KPluginFactoryList;
> 
> No static non-POD objects in libs (and also better not in apps)! You can use 
> K_GLOBAL_STATIC instead.
> 
>> +static void cleanupKPluginFactoryList()
>> +{
>> +  Q_FOREACH(KPluginFactory *f, s_KPluginFactoryList)
>> +    delete f;
> 
> you could use qDeleteAll
> 
>> +}
>> +
>>  Editor *KTextEditor::editor(const char *libname)
>>  {
>>    KPluginFactory *fact=KPluginLoader(libname).factory();
>>  
>>    KTextEditor::Factory *ef=qobject_cast<KTextEditor::Factory*>(fact);
>>  
>> -  if (!ef) return 0;
>> +  if (!ef) {
>> +    delete fact;
>> +    return 0;
>> +  }
>>  
>> +  if(s_KPluginFactoryList.count() == 0)
>> +    qAddPostRoutine(cleanupKPluginFactoryList);
>> +  s_KPluginFactoryList += fact;
>> +
>>    return ef->editor();
>>  }
> 
> I'd do it this way:
> 
> struct KTextEditorFactoryList : public QList
> {
>   KTextEditorFactoryList();
>   ~KTextEditorFactoryList() { qDeleteAll(*this); }
> };
> K_GLOBAL_STATIC(KTextEditorFactoryList, s_factoryList)
> KTextEditorFactoryList::KTextEditorFactoryList
> {
>   qAddPostRoutine(s_factoryList.destroy);
> }
> 
> then in ::editor you only need to add:
>   *s_factoryList += ef;
> 
Thx, I'll fix it this way and check it in afterwards.


Christian

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 258 bytes
Desc: OpenPGP digital signature
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20080302/c5823996/attachment.sig>


More information about the kde-core-devel mailing list