Author: cazfi
Date: Wed Jan  7 08:19:44 2015
New Revision: 27566

URL: http://svn.gna.org/viewcvs/freeciv?rev=27566&view=rev
Log:
Made Qt modpack installer thread synchornization to work with signals/slots.

See bug #23067

Modified:
    branches/S2_6/tools/mpgui_qt.cpp
    branches/S2_6/tools/mpgui_qt.h

Modified: branches/S2_6/tools/mpgui_qt.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/tools/mpgui_qt.cpp?rev=27566&r1=27565&r2=27566&view=diff
==============================================================================
--- branches/S2_6/tools/mpgui_qt.cpp    (original)
+++ branches/S2_6/tools/mpgui_qt.cpp    Wed Jan  7 08:19:44 2015
@@ -69,7 +69,8 @@
                                enum modpack_type type, const char *subtype,
                                const char *notes);
 static void msg_callback(const char *msg);
-static void progress_callback(int downloaded, int max);
+static void msg_callback_thr(const char *msg);
+static void progress_callback_thr(int downloaded, int max);
 
 static void gui_download_modpack(QString URL);
 
@@ -159,11 +160,19 @@
 }
 
 /**************************************************************************
+  Progress indications from downloader thread
+**************************************************************************/
+static void msg_callback_thr(const char *msg)
+{
+  gui->display_msg_thr(msg);
+}
+
+/**************************************************************************
   Progress indications from downloader
 **************************************************************************/
-static void progress_callback(int downloaded, int max)
-{
-  gui->progress(downloaded, max);
+static void progress_callback_thr(int downloaded, int max)
+{
+  gui->progress_thr(downloaded, max);
 }
 
 /**************************************************************************
@@ -216,6 +225,8 @@
 
   connect(mplist_table, SIGNAL(cellClicked(int, int)), this, 
SLOT(row_selected(int, int)));
   connect(mplist_table, SIGNAL(doubleClicked(QModelIndex)), this, 
SLOT(row_download(QModelIndex)));
+  connect(this, SIGNAL(display_msg_thr_signal(const char *)), this, 
SLOT(display_msg(const char *)));
+  connect(this, SIGNAL(progress_thr_signal(int, int)), this, 
SLOT(progress(int, int)));
 
   main_layout->addWidget(mplist_table);
 
@@ -260,12 +271,28 @@
 }
 
 /**************************************************************************
+  Display status message from another thread
+**************************************************************************/
+void mpgui::display_msg_thr(const char *msg)
+{
+  emit display_msg_thr_signal(msg);
+}
+
+/**************************************************************************
   Update progress bar
 **************************************************************************/
 void mpgui::progress(int downloaded, int max)
 {
   bar->setMaximum(max);
   bar->setValue(downloaded);
+}
+
+/**************************************************************************
+  Update progress bar from another thread
+**************************************************************************/
+void mpgui::progress_thr(int downloaded, int max)
+{
+  emit progress_thr_signal(downloaded, max);
 }
 
 /**************************************************************************
@@ -282,7 +309,7 @@
     worker = new mpqt_worker;
   }
 
-  worker->download(URL, gui, &fcmp, msg_callback, progress_callback);
+  worker->download(URL, gui, &fcmp, msg_callback_thr, progress_callback_thr);
 }
 
 /**************************************************************************

Modified: branches/S2_6/tools/mpgui_qt.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/tools/mpgui_qt.h?rev=27566&r1=27565&r2=27566&view=diff
==============================================================================
--- branches/S2_6/tools/mpgui_qt.h      (original)
+++ branches/S2_6/tools/mpgui_qt.h      Wed Jan  7 08:19:44 2015
@@ -35,13 +35,21 @@
 
   public:
     void setup(QWidget *central, struct fcmp_params *fcmp);
-    void display_msg(const char *msg);
-    void progress(int downloaded, int max);
+    void display_msg_thr(const char *msg);
+    void progress_thr(int downloaded, int max);
     void setup_list(const char *name, const char *URL,
                     const char *version, const char *license,
                     enum modpack_type type, const char *subtype,
                     const char *notes);
     void refresh_list_versions();
+
+  signals:
+    void display_msg_thr_signal(const char *msg);
+    void progress_thr_signal(int downloaded, int max);
+
+  public slots:
+    void display_msg(const char *msg);
+    void progress(int downloaded, int max);
 
   private slots:
     void URL_given();


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to