I forgot to include mitk-users previously - sorry
> We expect InitializeQt to be called once (well, it can be called multiple 
> times, but it only will only do something once) and that is the only place 
> where getQApplication is called.
Yes and no. If I want to use QtSingleApplication methods alike isRunning and 
sendMessage then I need to have QApplication before run methods because if 
application is already running then there is no sense to check for `isRunning` 
- it's obviously can't be running if it's QtSingleApplication... and that's why 
getQApplication will be called before initializeQt and qApp will
exist there

However if qApp is exist already I still need initializeQt to be called to move 
settings from mitkBaseApplication to qApp and that's why getters in this method 
should not get settings from qApp =) it should get settings from mitk Base App.

From: c.g...@dkfz-heidelberg.de
To: mikhail.pukhli...@outlook.com
Date: Thu, 10 Sep 2015 11:29:33 +0200
Subject: AW: AW: [mitk-users] mitk::BaseApplication can't set OrganizationName

Hi Mikhail, we can discuss this in the pull request, but some short comments. > 
QString appName = this->getApplicationName() shouldn't use qApp name I 
understand that this might be inconvenient for your special use case (because 
you need to hand the name through at several places), but for us this makes 
sense. There is already a place where the application name is stored (within 
Qt) and accessing it from us or directly via the qApp should return the same 
result. > if (qApp) return; should be replaced with if (qApp == nullptr) 
this->getQApplication(); Why? We expect InitializeQt to be called once (well, 
it can be called multiple times, but it only will only do something once) and 
that is the only place where getQApplication is called. For us it makes sense 
to have the function do what its name says and handle the initialization of the 
qApp, as in handle setting name/organization…We do not want to overwrite 
already set members of an existing qApp. There might be a reason they have been 
changed since initialization. Is there a special reason you did not CC the 
users list? Best,Caspar Von: Pukhlikov Mikhail 
[mailto:mikhail.pukhli...@outlook.com] 
Gesendet: Donnerstag, 10. September 2015 09:21
An: Goch, Caspar Jonas
Betreff: RE: AW: [mitk-users] mitk::BaseApplication can't set OrganizationName 
Hello! I've fixed it locally, in near time I may try to suggest change via pull 
request according this behaviour. in nutshell QString appName = 
this->getApplicationName() shouldn't use qApp name

and if (qApp) return; should be replaced with if (qApp == nullptr) 
this->getQApplication();From: c.g...@dkfz-heidelberg.de
To: mikhail.pukhli...@outlook.com; mitk-users@lists.sourceforge.net
Date: Wed, 9 Sep 2015 16:42:42 +0200
Subject: AW: [mitk-users] mitk::BaseApplication can't set OrganizationNameHi 
Mikhail, did I understand correctly that this issue only appears if you create 
the QtSingleApplication yourself in your own method? You might want to take a 
look at how we handle the Qt application creation in  void 
BaseApplication::initializeQt(){  if (qApp) return;   // If previously 
parameters have been set we have to store them  // to hand them through to the 
application  QString appName = this->getApplicationName();  QString orgName = 
this->getOrganizationName();  QString orgDomain = 
this->getOrganizationDomain();   // Create a QCoreApplication instance  
this->getQApplication();   // provide parameters to QCoreApplication  
this->setApplicationName(appName);  this->setOrganizationName(orgName);  
this->setOrganizationDomain(orgDomain);} basically we store the names 
separately as long as the application does not exist yet and upon creation hand 
them through. Does this fit your problem? Best,Caspar  Von: Pukhlikov Mikhail 
[mailto:mikhail.pukhli...@outlook.com] 
Gesendet: Donnerstag, 3. September 2015 14:57
An: mitk-users@lists.sourceforge.net
Betreff: [mitk-users] mitk::BaseApplication can't set OrganizationName Good 
evening mitk::BaseApplication can't set OrganizationName if getQApplication 
will be used before run() It's very complicated behaviour but I will try to 
explain how to reproduce it: To use QtSingleApplication I set 
myApp.setSingleMode(true); this way it will create QtSingleApplication but 
there actually more things that I wanted to do with it: I've added methods 
alike isRunning and sendMessage - and I need to use it before qApp will be 
created because if qApp will be created I actually will not even be able to get 
in there... So if I call those methods by adding methods to BaseApplication 
alike: void BaseApplication::sendMessage(const QByteArray msg){  
QmitkSingleApplication* qCoreApp =    
dynamic_cast<QmitkSingleApplication*>(this->getQApplication());  if (qCoreApp 
!= nullptr)  {    qCoreApp->sendMessage(msg);  }} then qCoreApp is creating and 
when it does myApp.run doesn't have qApp on initialize stage and then when 
initializeQt is called it gets out with : if (qApp) return; then my application 
ignore organization name and just creates it's folder in AppData/local which 
breaks other logics... How to deal with mitk::BaseApplication to be able to use 
isRunning and sendMessage QtSingleApplication methods? Thank you.               
                      
------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
_______________________________________________
mitk-users mailing list
mitk-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to