Dear Alex,

the color patch looks fine. Unfortunately with your other patch I get crashes 
on ubuntu. Ît only works the first time after a clean restart of the 
application.

I will look into it further.


Peter


________________________________
Von: Neher, Peter <p.ne...@dkfz-heidelberg.de>
Gesendet: Montag, 24. Juni 2019 09:02
An: Alex Lisovich
Cc: mitk-users@lists.sourceforge.net
Betreff: Re: [mitk-users] org.mitk.gui.qt.python plugin fails to run on Windows

Great thank you for your effort! I will take a look at it asap.

Von: Alex Lisovich <alex.lisov...@gmail.com>
Gesendet: Donnerstag, 20. Juni 2019 18:25
An: Neher, Peter <p.ne...@dkfz-heidelberg.de>
Cc: mitk-users@lists.sourceforge.net
Betreff: Re: [mitk-users] org.mitk.gui.qt.python plugin fails to run on Windows

Dear Peter,

I've just entered the issue into your bug tracking system. Here is the exerpt 
from the issue text:

My environment:
Windows 7 64bit ; VS 2017 Professional, Qt 5.12.3, Python 3.5.2 (Anaconda 4.2.0 
bundle)

Short  technical description of the problem:
 The reason for the crash lies in the fact that the first attempt to use the 
mitk::PythonService happens within the mitk::PythonService() constructor 
(within mitk::PythonActivator::Load() method) as part of Python static 
initialization and BEFORE the service gets registed thorugh the 
m_PythonServiceRegistration = 
context->RegisterService<mitk::IPythonService>(m_PythonService.GetPointer(), 
_PythonServiceProps); call within the same  mitk::PythonActivator::Load()    
method.

Short technical description of the fix:
The idea of the fix is to defer the first query for the PythonService until  
the service is register by moving all python initialization related  the 
mitk::PythonService() constructor functionality into new separate Initialize() 
method (also defining it within the IPythonService abstrct class) and calling 
this Initialize() method within the mitk:: QmitkPythonVariableStackTableModel() 
constructor.
Debugging the modified code has shown that now the first PythonService query 
indeed happens after it was actually registered which resolved the problem.

 I am also attaching the diff file (PythoPluginDiff.txt) of all modifications 
I've made to resolve the issue which can be used as a patch (did not find how I 
can attach it to the bug report)

Regarding my second question (fixing the colors for Dark Theme), I am attaching 
the second diff file ()containing modification to QmitkCtkPythonShell() 
constructor which made the Python console text pretty readable.


On Wed, Jun 19, 2019 at 6:09 AM Neher, Peter 
<p.ne...@dkfz-heidelberg.de<mailto:p.ne...@dkfz-heidelberg.de>> wrote:
Dear Alex,

If I recall correctly, this feature worked for me when I last tried it a couple 
of weeks ago. Maybe it’s a Qt issue. Which Qt version are you using? Also could 
you enter this issue in our bug tracking system including your quick fix? 
https://phabricator.mitk.org/

I am currently out of office, but I can take a look at it when I am back.

Cheers,
Peter

Von: Alex Lisovich <alex.lisov...@gmail.com<mailto:alex.lisov...@gmail.com>>
Gesendet: Dienstag, 18. Juni 2019 00:44
An: mitk-users@lists.sourceforge.net<mailto:mitk-users@lists.sourceforge.net>
Betreff: Re: [mitk-users] org.mitk.gui.qt.python plugin fails to run on Windows

Dear All,

Sorry for a long post, but here it goes:

For the last few days I was trying to compile/run the org.mitk.gui.qt.python 
Python pligin.
Basically, it compiles just fine, but when trying to load (both in Release and 
Debug mode) it generates (and displays instead of Python console) the following 
message: "Part Initialization Error: Default constructed ServiceReference is 
not valid input to GetService()".

Running it in Debug mode revealed that this is the result of throwing the 
exception within the ModuleContext::GetService(const ServiceReferenceBase& 
reference) as a result of PythonService not being registered at the moment of 
call which in turn happens within the mitk::PythonActivator::Load() during the 
call to PythonService constructor and BEFORE the PythonService is actually get 
registered.

Further digging in MITK forum archives, I came along the thread  [mitk-users] 
Can't run Python 
plugin<https://sourceforge.net/p/mitk/mailman/message/34810888/>  initiated by 
Matt Clarkson  describing exactly the same problem and dated back to 2016. 
During the discussion, Miklos Espak provided the explanation for this 
phenomenon (bug in PythonQT related to static variables initialization) and 
outlined 3 ways to fix the problem, second of them being moving all PythonQT 
initialization related code from the static initialization.

Using his second suggestion I was able to successfully implement "quick and 
dirty" fix allowing to plugin load and run just fine (including SimpleITK 
import, images drag and drop, simple processing etc).

So after all this hassle, I basically have two questions:

(1) It looks the Python plugin has been broken on Windows since 2016 and likely 
since MITK 2015 release (that's what Miklos is saying in thread above). Was 
anybody able to successfully run it on Windows since then, and if yes, was it 
fixed somehow outside of the master branch or I am missing something?

(2) The Python Console window text colors are such that it is practically 
impossible to see anything you type (in "Light" theme it is fine). Does anybody 
know if there is some qml (or xml) file with default colors I can modify (the 
colorare defined as Q_PROPERTY's within the code)?


P.S. I am running Windows 7 64 bit, the MITK was configured using CMake 3.14.3 
and compiled on VS 2017 Professional.


Best Regards, and sorry again for a supre-long post,

Alex




_______________________________________________
mitk-users mailing list
mitk-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to