#
# patch "main.cc"
# from [0203c798531c12adf0e75354c7c1811bf95c09bf]
# to [a60b92b85a3e6e0b8537d79149f679dd0224ad19]
#
# patch "monotone.cc"
# from [919b8cbcd5e06a3c0c33b8e1223bd7bdc2bbaa63]
# to [a738042de602184b65c94272e2913e4ca4835d31]
#
# patch "monotone.hh"
# from [0c12a29da47fe9c6ec1f234ce9cd9fc6abe1e30a]
# to [87cf2c03ca9f43cffac94aadf90b022f7d495650]
#
========================================================================
--- main.cc 0203c798531c12adf0e75354c7c1811bf95c09bf
+++ main.cc a60b92b85a3e6e0b8537d79149f679dd0224ad19
@@ -42,6 +42,12 @@
}
};
+void on_delay()
+{
+ while (Gtk::Main::events_pending())
+ Gtk::Main::iteration();
+}
+
class mainwin : public Gtk::Window
{
monotone mtn;
@@ -136,6 +142,7 @@
}
mainwin(): rd(&mtn, this)
{
+ mtn.set_longwait_callback(&on_delay);
set_default_size(675, 400);
ag = Gtk::ActionGroup::create();
ag->add(Gtk::Action::create("Setdir", Gtk::Stock::OPEN, "Set working dir"),
========================================================================
--- monotone.cc 919b8cbcd5e06a3c0c33b8e1223bd7bdc2bbaa63
+++ monotone.cc a738042de602184b65c94272e2913e4ca4835d31
@@ -1,9 +1,10 @@
// Copyright 2005 Timothy Brownawell
// Licensed to the public under the GNU GPL v2, see COPYING
#include "monotone.hh"
#include
+#include
#include
#include
#include
@@ -21,7 +22,7 @@
inline int max(int a, int b) {return (a>b)?a:b;}
-monotone::monotone(): pid(-1)
+monotone::monotone(): pid(-1), lwcb(0)
{
}
@@ -30,6 +31,12 @@
stop();
}
+void
+monotone::set_longwait_callback(longwait_callback lc)
+{
+ lwcb = lc;
+}
+
bool
monotone::execute(std::vector args)
{
@@ -107,6 +114,8 @@
bool
monotone::stopped()
{
+ if (lwcb)
+ lwcb();
if (pid == -1)
return true;
int r = waitpid(pid, 0, WNOHANG);
@@ -123,7 +132,7 @@
int got = 0;
int minsize = 8;
int c1(0), c2(0), c3(0), c4(0);
- while (!c4 && !stopped())
+ while (!stopped() && !c4)
{
int r = read(from, head+got, minsize-got);
got += r;
@@ -177,7 +186,7 @@
int r = read(from, output, size - got);
got += r;
out += std::string(output, r);
- } while (got != size && !stopped());
+ } while (!stopped() && got != size);
if (stopped())
return false;
return m;
@@ -196,7 +205,7 @@
s << i->size() << ":" << *i;
std::string c = "l" + s.str() + "e";
write(to, c.c_str(), c.size());
- while(read_packet(res) && !stopped())
+ while(!stopped() && read_packet(res))
;
return res;
}
@@ -219,13 +228,16 @@
fd_set rd, ex;
do
{
+ timeval timeout;
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 100000;
FD_ZERO(&rd);
FD_ZERO(&ex);
FD_SET(from, &rd);
FD_SET(errfrom, &rd);
FD_SET(from, &ex);
FD_SET(errfrom, &ex);
- int s = ::select(max(from, errfrom)+1, &rd, 0, &ex, 0);
+ int s = ::select(max(from, errfrom)+1, &rd, 0, &ex, &timeout);
if (FD_ISSET(from, &rd))
{
int r = read(from, output, size);
========================================================================
--- monotone.hh 0c12a29da47fe9c6ec1f234ce9cd9fc6abe1e30a
+++ monotone.hh 87cf2c03ca9f43cffac94aadf90b022f7d495650
@@ -35,6 +35,8 @@
bool trusted;
};
+typedef void(*longwait_callback)();
+
class monotone
{
pid_t pid;
@@ -50,9 +52,11 @@
bool stopped();
bool read_header(int & cmdnum, int & err, bool & more, int & size);
bool read_packet(std::string & out);
+ longwait_callback lwcb;
public:
monotone();
~monotone();
+ void set_longwait_callback(longwait_callback lc);
void set_dir(std::string const & s){dir = s; stop();}
void set_db(std::string const & s){db = s; stop();}
std::string get_dir(){return dir;}