forked from osmocom/wireshark
Qt: Fix windows version of Preference Dialog
Initializing a static member on Windows C++ has to be done differently. This fixes the segfault introduced with Ia611ec192dcc1ad638a997182cec1ab5bdb7859c Change-Id: Ib7a9840feda74830f835345c666f57e23e9e4e0b Reviewed-on: https://code.wireshark.org/review/25163 Reviewed-by: Roland Knall <rknall@gmail.com> Petri-Dish: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
parent
82b26b686e
commit
3b64fc008f
|
@ -16,7 +16,11 @@
|
||||||
|
|
||||||
PreferenceFactory::~PreferenceFactory() {}
|
PreferenceFactory::~PreferenceFactory() {}
|
||||||
|
|
||||||
QMap<int, PreferenceFactory *> PreferenceManager::factories;
|
QMap<int, PreferenceFactory *> & PreferenceManager::factories()
|
||||||
|
{
|
||||||
|
static QMap<int, PreferenceFactory *> inst = QMap<int, PreferenceFactory *>();
|
||||||
|
return inst;
|
||||||
|
}
|
||||||
|
|
||||||
PreferenceManager::PreferenceManager(QObject * parent)
|
PreferenceManager::PreferenceManager(QObject * parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
|
@ -25,7 +29,7 @@ PreferenceManager::PreferenceManager(QObject * parent)
|
||||||
PreferenceManager::~PreferenceManager()
|
PreferenceManager::~PreferenceManager()
|
||||||
{
|
{
|
||||||
/* As this is a singleton, this is the point, where we can clear the registry */
|
/* As this is a singleton, this is the point, where we can clear the registry */
|
||||||
PreferenceManager::factories.clear();
|
PreferenceManager::factories().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
PreferenceManager * PreferenceManager::instance()
|
PreferenceManager * PreferenceManager::instance()
|
||||||
|
@ -41,10 +45,10 @@ void PreferenceManager::registerType(int pref, PreferenceFactory * factory)
|
||||||
{
|
{
|
||||||
Q_ASSERT(pref >= 0);
|
Q_ASSERT(pref >= 0);
|
||||||
|
|
||||||
if ( PreferenceManager::factories.contains(pref) || ! factory )
|
if ( PreferenceManager::factories().contains(pref) || ! factory )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PreferenceManager::factories[pref] = factory;
|
PreferenceManager::factories()[pref] = factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
WiresharkPreference * PreferenceManager::getPreference(PrefsItem * pref)
|
WiresharkPreference * PreferenceManager::getPreference(PrefsItem * pref)
|
||||||
|
@ -53,11 +57,11 @@ WiresharkPreference * PreferenceManager::getPreference(PrefsItem * pref)
|
||||||
return Q_NULLPTR;
|
return Q_NULLPTR;
|
||||||
|
|
||||||
int key = pref->getPrefType();
|
int key = pref->getPrefType();
|
||||||
if ( ! PreferenceManager::factories.contains(key) )
|
if ( ! PreferenceManager::factories().contains(key) )
|
||||||
return Q_NULLPTR;
|
return Q_NULLPTR;
|
||||||
|
|
||||||
/* All actions are parented with this manager, to clear the objects together with the manager */
|
/* All actions are parented with this manager, to clear the objects together with the manager */
|
||||||
WiresharkPreference * wspref = qobject_cast<WiresharkPreference *>(PreferenceManager::factories[key]->create(this));
|
WiresharkPreference * wspref = qobject_cast<WiresharkPreference *>(PreferenceManager::factories()[key]->create(this));
|
||||||
if ( wspref )
|
if ( wspref )
|
||||||
wspref->setPrefsItem(pref);
|
wspref->setPrefsItem(pref);
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ protected:
|
||||||
explicit PreferenceManager(QObject * parent = Q_NULLPTR);
|
explicit PreferenceManager(QObject * parent = Q_NULLPTR);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QMap<int, PreferenceFactory*> factories;
|
static QMap<int, PreferenceFactory*> & factories();
|
||||||
};
|
};
|
||||||
|
|
||||||
class PreferenceFactory : public QObject
|
class PreferenceFactory : public QObject
|
||||||
|
|
Loading…
Reference in New Issue