Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
6882c3cc
Commit
6882c3cc
authored
Dec 16, 2009
by
ck
Browse files
Maemo: Fix "race condition" in singleton access.
parent
de64a463
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/plugins/qt4projectmanager/qt-maemo/maemodeviceconfigurations.cpp
View file @
6882c3cc
...
...
@@ -87,7 +87,8 @@ MaemoDeviceConfigurations::DeviceConfig::DeviceConfig(const QString &name)
{
}
MaemoDeviceConfigurations
::
DeviceConfig
::
DeviceConfig
(
const
QSettings
&
settings
)
MaemoDeviceConfigurations
::
DeviceConfig
::
DeviceConfig
(
const
QSettings
&
settings
,
quint64
&
nextId
)
:
name
(
settings
.
value
(
NameKey
).
toString
()),
type
(
static_cast
<
DeviceType
>
(
settings
.
value
(
TypeKey
,
Physical
).
toInt
())),
host
(
settings
.
value
(
HostKey
).
toString
()),
...
...
@@ -97,11 +98,10 @@ MaemoDeviceConfigurations::DeviceConfig::DeviceConfig(const QSettings &settings)
pwd
(
settings
.
value
(
PasswordKey
).
toString
()),
keyFile
(
settings
.
value
(
KeyFileKey
).
toString
()),
timeout
(
settings
.
value
(
TimeoutKey
,
30
).
toInt
()),
internalId
(
settings
.
value
(
InternalIdKey
,
MaemoDeviceConfigurations
::
instance
().
m_
nextId
).
toInt
())
internalId
(
settings
.
value
(
InternalIdKey
,
nextId
).
toInt
())
{
if
(
internalId
==
MaemoDeviceConfigurations
::
instance
().
m_nextId
)
++
MaemoDeviceConfigurations
::
instance
().
m_nextId
;
qDebug
(
"%s: name = %s, id = %llu"
,
Q_FUNC_INFO
,
qPrintable
(
name
),
internalId
);
if
(
internalId
==
nextId
)
++
nextId
;
}
MaemoDeviceConfigurations
::
DeviceConfig
::
DeviceConfig
()
...
...
@@ -146,7 +146,6 @@ void MaemoDeviceConfigurations::save()
{
QSettings
*
settings
=
Core
::
ICore
::
instance
()
->
settings
();
settings
->
beginGroup
(
SettingsGroup
);
qDebug
(
"Writing next id: %llu"
,
m_nextId
);
settings
->
setValue
(
IdCounterKey
,
m_nextId
);
settings
->
beginWriteArray
(
ConfigListKey
,
m_devConfigs
.
count
());
for
(
int
i
=
0
;
i
<
m_devConfigs
.
count
();
++
i
)
{
...
...
@@ -169,11 +168,10 @@ void MaemoDeviceConfigurations::load()
QSettings
*
settings
=
Core
::
ICore
::
instance
()
->
settings
();
settings
->
beginGroup
(
SettingsGroup
);
m_nextId
=
settings
->
value
(
IdCounterKey
,
1
).
toULongLong
();
qDebug
(
"Read next id: %llu"
,
m_nextId
);
int
count
=
settings
->
beginReadArray
(
ConfigListKey
);
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
settings
->
setArrayIndex
(
i
);
m_devConfigs
.
append
(
DeviceConfig
(
*
settings
));
m_devConfigs
.
append
(
DeviceConfig
(
*
settings
,
m_nextId
));
}
settings
->
endArray
();
settings
->
endGroup
();
...
...
@@ -181,21 +179,17 @@ void MaemoDeviceConfigurations::load()
MaemoDeviceConfigurations
::
DeviceConfig
MaemoDeviceConfigurations
::
find
(
const
QString
&
name
)
const
{
qDebug
(
"%s: Looking for name %s"
,
Q_FUNC_INFO
,
qPrintable
(
name
));
QList
<
DeviceConfig
>::
ConstIterator
resultIt
=
std
::
find_if
(
m_devConfigs
.
constBegin
(),
m_devConfigs
.
constEnd
(),
DevConfNameMatcher
(
name
));
qDebug
(
"Found: %d"
,
resultIt
!=
m_devConfigs
.
constEnd
());
return
resultIt
==
m_devConfigs
.
constEnd
()
?
DeviceConfig
()
:
*
resultIt
;
}
MaemoDeviceConfigurations
::
DeviceConfig
MaemoDeviceConfigurations
::
find
(
int
id
)
const
{
qDebug
(
"%s: Looking for id %d"
,
Q_FUNC_INFO
,
id
);
QList
<
DeviceConfig
>::
ConstIterator
resultIt
=
std
::
find_if
(
m_devConfigs
.
constBegin
(),
m_devConfigs
.
constEnd
(),
DevConfIdMatcher
(
id
));
qDebug
(
"Found: %d"
,
resultIt
!=
m_devConfigs
.
constEnd
());
return
resultIt
==
m_devConfigs
.
constEnd
()
?
DeviceConfig
()
:
*
resultIt
;
}
...
...
src/plugins/qt4projectmanager/qt-maemo/maemodeviceconfigurations.h
View file @
6882c3cc
...
...
@@ -59,7 +59,7 @@ public:
enum
AuthType
{
Password
,
Key
};
DeviceConfig
();
DeviceConfig
(
const
QString
&
name
);
DeviceConfig
(
const
QSettings
&
settings
);
DeviceConfig
(
const
QSettings
&
settings
,
quint64
&
nextId
);
void
save
(
QSettings
&
settings
)
const
;
bool
isValid
()
const
;
QString
name
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment