Skip to content

Commit

Permalink
ApplicationConfig: fix lazy reloading of Qt (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
machinekoder committed Mar 17, 2017
1 parent f92ec46 commit 2e68de8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/application/applicationconfig.cpp
Expand Up @@ -164,11 +164,12 @@ namespace qtquickvcp {
Unselects the configuration with the given name and updates \l{selectedConfig}.
*/
ApplicationConfig::ApplicationConfig(QObject *parent) :
application::ConfigBase(parent),
m_synced(false),
m_selectedConfig(new ApplicationConfigItem(this)),
m_filter(new ApplicationConfigFilter(this))
ApplicationConfig::ApplicationConfig(QObject *parent)
: application::ConfigBase(parent)
, m_synced(false)
, m_selectedConfig(new ApplicationConfigItem(this))
, m_filter(new ApplicationConfigFilter(this))
, m_tmpPath("")
{
}

Expand All @@ -181,8 +182,7 @@ void ApplicationConfig::cleanupFiles()
{
if (!m_selectedConfig->name().isEmpty())
{
QString path = MachinetalkService::applicationTempPath(m_selectedConfig->name());
QDir dir(path);
QDir dir(m_tmpPath);
dir.removeRecursively();
}
}
Expand Down Expand Up @@ -246,7 +246,9 @@ void ApplicationConfig::applicationDetailReceived(const Container &rx)
m_selectedConfig->setDescription(QString::fromStdString(app.description()));
m_selectedConfig->setType(type);

baseFilePath = MachinetalkService::applicationTempPath(m_selectedConfig->name());
// update the tmp path and use it to store the config, UUID enforces reload of UI
m_tmpPath = MachinetalkService::applicationTempPath(m_selectedConfig->name() + "-" + QUuid::createUuid().toString().remove('{').remove('}'));
baseFilePath = m_tmpPath;
if (!dir.mkpath(baseFilePath))
{
qWarning() << "unable to create directory " << baseFilePath;
Expand Down
1 change: 1 addition & 0 deletions src/application/applicationconfig.h
Expand Up @@ -99,6 +99,7 @@ public slots:
ApplicationConfigItem *m_selectedConfig;
QList<ApplicationConfigItem*> m_configs;
ApplicationConfigFilter *m_filter;
QString m_tmpPath;

// more efficient to reuse a protobuf Message
machinetalk::Container m_tx;
Expand Down

0 comments on commit 2e68de8

Please sign in to comment.