]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/Timeout_pimpl.C
fix crash with "save as"
[lyx.git] / src / frontends / xforms / Timeout_pimpl.C
1 /**
2  * \file xforms/Timeout_pimpl.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Lars Gullik Bjønnes
7  * \author John Levon
8  *
9  * Full author contact details are available in file CREDITS
10  */
11
12 #include <config.h>
13
14 #include FORMS_H_LOCATION
15
16 #ifdef __GNUG__
17 #pragma implementation
18 #endif
19
20 #include "Timeout_pimpl.h"
21 #include "debug.h"
22
23 using std::endl;
24
25 namespace {
26
27 extern "C" {
28
29 static
30 void C_intern_timeout_cb(int, void * data)
31 {
32         Timeout * to = static_cast<Timeout *>(data);
33         to->emit();
34 }
35
36 }
37
38 } // namespace anon
39
40
41 Timeout::Pimpl::Pimpl(Timeout * owner)
42         : owner_(owner), timeout_id(-1)
43 {
44 }
45
46
47 void Timeout::Pimpl::reset()
48 {
49         timeout_id = -1;
50 }
51
52
53 bool Timeout::Pimpl::running() const
54 {
55         return timeout_id != -1;
56 }
57
58
59 void Timeout::Pimpl::start()
60 {
61         if (timeout_id != -1)
62                 lyxerr << "Timeout::start: already running!" << endl;
63         timeout_id = fl_add_timeout(owner_->timeout_ms,
64                                     C_intern_timeout_cb, owner_);
65 }
66
67
68 void Timeout::Pimpl::stop()
69 {
70         if (timeout_id != -1) {
71                 fl_remove_timeout(timeout_id);
72                 timeout_id = -1;
73         }
74 }