Hi 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