comparison data/fileio/FileFinder.h @ 622:43b0bfd07bd3

* Fix potential static initialiser race (FileFinder vs InteractiveFileFinder instance pointers)
author Chris Cannam
date Fri, 12 Mar 2010 14:53:44 +0000
parents 442e2ff876aa
children 1de00ee53be1
comparison
equal deleted inserted replaced
621:58c82e10ef00 622:43b0bfd07bd3
35 virtual QString getSaveFileName(FileType type, QString fallbackLocation = "") = 0; 35 virtual QString getSaveFileName(FileType type, QString fallbackLocation = "") = 0;
36 virtual void registerLastOpenedFilePath(FileType type, QString path) = 0; 36 virtual void registerLastOpenedFilePath(FileType type, QString path) = 0;
37 37
38 virtual QString find(FileType type, QString location, QString lastKnownLocation = "") = 0; 38 virtual QString find(FileType type, QString location, QString lastKnownLocation = "") = 0;
39 39
40 static FileFinder *getInstance() { return m_instance; } 40 static FileFinder *getInstance() {
41 FFContainer *container = FFContainer::getInstance();
42 return container->getFileFinder();
43 }
41 44
42 protected: 45 protected:
43 static void registerFileFinder(FileFinder *ff) { m_instance = ff; } 46 class FFContainer {
44 static FileFinder *m_instance; 47 public:
48 static FFContainer *getInstance() {
49 static FFContainer instance;
50 return &instance;
51 }
52 void setFileFinder(FileFinder *ff) { m_ff = ff; }
53 FileFinder *getFileFinder() const { return m_ff; }
54 private:
55 FileFinder *m_ff;
56 };
57
58 static void registerFileFinder(FileFinder *ff) {
59 FFContainer *container = FFContainer::getInstance();
60 container->setFileFinder(ff);
61 }
45 }; 62 };
46 63
47 #endif 64 #endif
48 65
49 66