You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
521 B
C++
32 lines
521 B
C++
7 years ago
|
#include "application.h"
|
||
|
|
||
|
Application::Application(int &argc, char **argv)
|
||
|
:QApplication(argc, argv)
|
||
|
{
|
||
|
m_single = new QSharedMemory("ShredMemoryForOneInstanceOfProdejnaApp", this);
|
||
|
}
|
||
|
|
||
|
Application::~Application()
|
||
|
{
|
||
|
if (m_single->isAttached())
|
||
|
{
|
||
|
m_single->detach();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
bool Application::lock()
|
||
|
{
|
||
|
if (m_single->attach(QSharedMemory::ReadOnly))
|
||
|
{
|
||
|
m_single->detach();
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
if (m_single->create(1))
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
}
|