Changed PreMods() and postMods() functions into signals in notifyqt so that these functions do not cause a data race when called from a callback in libretroshare.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1038 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2009-02-12 11:48:43 +00:00
parent 516b1684f9
commit 543e27a1da
5 changed files with 64 additions and 107 deletions

View File

@ -359,27 +359,21 @@ void SharedFilesDialog::openfolder()
void SharedFilesDialog::preModDirectories(bool update_local) void SharedFilesDialog::preModDirectories(bool update_local)
{ {
std::cerr << "SharedFilesDialog::preModDirectories called with update_local = " << update_local << std::endl ;
if (update_local) if (update_local)
{
localModel->preMods(); localModel->preMods();
}
else else
{
model->preMods(); model->preMods();
}
} }
void SharedFilesDialog::ModDirectories(bool update_local) void SharedFilesDialog::postModDirectories(bool update_local)
{ {
std::cerr << "SharedFilesDialog::postModDirectories called with update_local = " << update_local << std::endl ;
if (update_local) if (update_local)
{
localModel->postMods(); localModel->postMods();
}
else else
{
model->postMods(); model->postMods();
}
} }

View File

@ -41,13 +41,14 @@ public:
SharedFilesDialog(QWidget *parent = 0); SharedFilesDialog(QWidget *parent = 0);
/** Default Destructor */ /** Default Destructor */
/* For handling the model updates */
void preModDirectories(bool update_local);
void ModDirectories(bool update_local);
private slots: private slots:
/* For handling the model updates */
void preModDirectories(bool update_local);
void postModDirectories(bool update_local);
void checkUpdate(); void checkUpdate();
void forceCheck(); void forceCheck();

View File

@ -153,6 +153,8 @@ int main(int argc, char *argv[])
// avoid clashes between infos from threads. // avoid clashes between infos from threads.
// //
QObject::connect(notify,SIGNAL(hashingInfo(const QString&)),w,SLOT(updateHashingInfo(const QString&))) ; QObject::connect(notify,SIGNAL(hashingInfo(const QString&)),w,SLOT(updateHashingInfo(const QString&))) ;
QObject::connect(notify,SIGNAL(filesPreMod( bool)),w->sharedfilesDialog,SLOT(preModDirectories(bool))) ;
QObject::connect(notify,SIGNAL(filesPostMod( bool)),w->sharedfilesDialog,SLOT(postModDirectories(bool))) ;
/* only show window, if not startMinimized */ /* only show window, if not startMinimized */
if (!startMinimised) if (!startMinimised)

View File

@ -62,7 +62,8 @@ void NotifyQt::notifyListChange(int list, int type)
//displayFriends(); //displayFriends();
break; break;
case NOTIFY_LIST_DIRLIST: case NOTIFY_LIST_DIRLIST:
displayDirectories(); emit filesPostMod(false) ; /* Remote */
emit filesPostMod(true) ; /* Local */
break; break;
case NOTIFY_LIST_SEARCHLIST: case NOTIFY_LIST_SEARCHLIST:
//displaySearch(); //displaySearch();
@ -97,7 +98,8 @@ void NotifyQt::notifyListPreChange(int list, int type)
//preDisplayFriends(); //preDisplayFriends();
break; break;
case NOTIFY_LIST_DIRLIST: case NOTIFY_LIST_DIRLIST:
preDisplayDirectories(); emit filesPreMod(false) ; /* remote */
emit filesPreMod(true) ; /* local */
break; break;
case NOTIFY_LIST_SEARCHLIST: case NOTIFY_LIST_SEARCHLIST:
//preDisplaySearch(); //preDisplaySearch();
@ -279,53 +281,6 @@ void NotifyQt::displayFriends()
mWindow->insertPeers(); mWindow->insertPeers();
} }
void NotifyQt::preDisplayDirectories()
{
//iface->lockData(); /* Lock Interface */
#ifdef NOTIFY_DEBUG
std::ostringstream out;
out << "NotifyQt::preDisplayDirectories()" << std::endl;
std::cerr << out.str();
#endif
//iface->unlockData(); /* UnLock Interface */
if (dDialog)
{
dDialog->preModDirectories(false); /* Remote */
dDialog->preModDirectories(true); /* Local */
}
}
void NotifyQt::displayDirectories()
{
//iface->lockData(); /* Lock Interface */
#ifdef NOTIFY_DEBUG
std::ostringstream out;
out << "NotifyQt::displayDirectories()" << std::endl;
std::cerr << out.str();
#endif
//iface->unlockData(); /* UnLock Interface */
if (dDialog)
{
dDialog->ModDirectories(false); /* Remote */
dDialog->ModDirectories(true); /* Local */
}
}
void NotifyQt::displaySearch() void NotifyQt::displaySearch()
{ {
iface->lockData(); /* Lock Interface */ iface->lockData(); /* Lock Interface */

View File

@ -20,35 +20,40 @@ class MessengerWindow;
//class NotifyQt: public NotifyBase, public QObject //class NotifyQt: public NotifyBase, public QObject
class NotifyQt: public QObject, public NotifyBase class NotifyQt: public QObject, public NotifyBase
{ {
Q_OBJECT Q_OBJECT
public: public:
NotifyQt() : cDialog(NULL), pDialog(NULL), NotifyQt() : cDialog(NULL), pDialog(NULL),
dDialog(NULL), tDialog(NULL), dDialog(NULL), tDialog(NULL),
hDialog(NULL), mDialog(NULL), hDialog(NULL), mDialog(NULL),
sDialog(NULL), mWindow(NULL) sDialog(NULL), mWindow(NULL)
{ return; } { return; }
virtual ~NotifyQt() { return; } virtual ~NotifyQt() { return; }
void setNetworkDialog(NetworkDialog *c) { cDialog = c; } void setNetworkDialog(NetworkDialog *c) { cDialog = c; }
void setPeersDialog(PeersDialog *p) { pDialog = p; } void setPeersDialog(PeersDialog *p) { pDialog = p; }
void setDirDialog(SharedFilesDialog *d) { dDialog = d; } void setDirDialog(SharedFilesDialog *d) { dDialog = d; }
void setTransfersDialog(TransfersDialog *t) { tDialog = t; } void setTransfersDialog(TransfersDialog *t) { tDialog = t; }
void setChatDialog(ChatDialog *m) { hDialog = m; } void setChatDialog(ChatDialog *m) { hDialog = m; }
void setMessagesDialog(MessagesDialog *m) { mDialog = m; } void setMessagesDialog(MessagesDialog *m) { mDialog = m; }
void setChannelsDialog(ChannelsDialog *s) { sDialog = s; } void setChannelsDialog(ChannelsDialog *s) { sDialog = s; }
void setMessengerWindow(MessengerWindow *mw) { mWindow = mw; } void setMessengerWindow(MessengerWindow *mw) { mWindow = mw; }
void setRsIface(RsIface *i) { iface = i; } void setRsIface(RsIface *i) { iface = i; }
virtual void notifyListPreChange(int list, int type); virtual void notifyListPreChange(int list, int type);
virtual void notifyListChange(int list, int type); virtual void notifyListChange(int list, int type);
virtual void notifyErrorMsg(int list, int sev, std::string msg); virtual void notifyErrorMsg(int list, int sev, std::string msg);
virtual void notifyChat(); virtual void notifyChat();
virtual void notifyHashingInfo(std::string fileinfo); virtual void notifyHashingInfo(std::string fileinfo);
signals: signals:
// It's beneficial to send info to the GUI using signals, because signals are thread-safe
// as they get queued by Qt.
//
void hashingInfo(const QString&) const ; void hashingInfo(const QString&) const ;
void filesPreMod(bool) const ;
void filesPostMod(bool) const ;
public slots: public slots:
@ -56,34 +61,34 @@ virtual void notifyHashingInfo(std::string fileinfo);
private: private:
void displayNeighbours(); void displayNeighbours();
void displayFriends(); void displayFriends();
void displayDirectories(); // void displayDirectories();
void displaySearch(); void displaySearch();
void displayChat(); void displayChat();
void displayMessages(); void displayMessages();
void displayChannels(); void displayChannels();
void displayTransfers(); void displayTransfers();
void preDisplayNeighbours(); void preDisplayNeighbours();
void preDisplayFriends(); void preDisplayFriends();
void preDisplayDirectories(); // void preDisplayDirectories();
void preDisplaySearch(); void preDisplaySearch();
void preDisplayMessages(); void preDisplayMessages();
void preDisplayChannels(); void preDisplayChannels();
void preDisplayTransfers(); void preDisplayTransfers();
/* so we can update windows */ /* so we can update windows */
NetworkDialog *cDialog; NetworkDialog *cDialog;
PeersDialog *pDialog; PeersDialog *pDialog;
SharedFilesDialog *dDialog; SharedFilesDialog *dDialog;
TransfersDialog *tDialog; TransfersDialog *tDialog;
ChatDialog *hDialog; ChatDialog *hDialog;
MessagesDialog *mDialog; MessagesDialog *mDialog;
ChannelsDialog *sDialog; ChannelsDialog *sDialog;
MessengerWindow *mWindow; MessengerWindow *mWindow;
RsIface *iface; RsIface *iface;
}; };
#endif #endif