rewritten fluxbox-restart code, all destructors are called before the
new program is started. the former method didnt do that.
This commit is contained in:
parent
2760b03b2e
commit
496d73d899
3 changed files with 55 additions and 31 deletions
|
@ -22,7 +22,7 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// $Id: fluxbox.cc,v 1.258 2004/10/10 16:06:23 akir Exp $
|
||||
// $Id: fluxbox.cc,v 1.259 2004/10/18 01:26:54 akir Exp $
|
||||
|
||||
#include "fluxbox.hh"
|
||||
|
||||
|
@ -238,6 +238,7 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile
|
|||
m_rc_file(rcfilename ? rcfilename : ""),
|
||||
m_argv(argv), m_argc(argc),
|
||||
m_starting(true),
|
||||
m_restarting(false),
|
||||
m_shutdown(false),
|
||||
m_server_grabs(0),
|
||||
m_randr_event_type(0),
|
||||
|
@ -457,6 +458,7 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile
|
|||
|
||||
|
||||
Fluxbox::~Fluxbox() {
|
||||
|
||||
// destroy toolbars
|
||||
while (!m_toolbars.empty()) {
|
||||
delete m_toolbars.back();
|
||||
|
@ -1357,14 +1359,11 @@ void Fluxbox::removeGroupSearch(Window window) {
|
|||
void Fluxbox::restart(const char *prog) {
|
||||
shutdown();
|
||||
|
||||
if (prog) {
|
||||
execlp(prog, prog, 0);
|
||||
perror(prog);
|
||||
}
|
||||
m_restarting = true;
|
||||
|
||||
// fall back in case the above execlp doesn't work
|
||||
execvp(m_argv[0], m_argv);
|
||||
execvp(StringUtil::basename(m_argv[0]).c_str(), m_argv);
|
||||
if (prog) {
|
||||
m_restart_argument = prog;
|
||||
}
|
||||
}
|
||||
|
||||
/// prepares fluxbox for a shutdown
|
||||
|
@ -1377,7 +1376,8 @@ void Fluxbox::shutdown() {
|
|||
XSetInputFocus(FbTk::App::instance()->display(), PointerRoot, None, CurrentTime);
|
||||
|
||||
//send shutdown to all screens
|
||||
for_each(m_screen_list.begin(), m_screen_list.end(), mem_fun(&BScreen::shutdown));
|
||||
for_each(m_screen_list.begin(),
|
||||
m_screen_list.end(), mem_fun(&BScreen::shutdown));
|
||||
|
||||
sync(false);
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// $Id: fluxbox.hh,v 1.92 2004/10/10 16:06:24 akir Exp $
|
||||
// $Id: fluxbox.hh,v 1.93 2004/10/18 01:26:54 akir Exp $
|
||||
|
||||
#ifndef FLUXBOX_HH
|
||||
#define FLUXBOX_HH
|
||||
|
@ -204,6 +204,9 @@ public:
|
|||
void timed_reconfigure();
|
||||
|
||||
bool isStartup() const { return m_starting; }
|
||||
bool isRestarting() const { return m_restarting; }
|
||||
|
||||
const std::string &getRestartArgument() const { return m_restart_argument; }
|
||||
|
||||
/// get screen from number
|
||||
BScreen *findScreen(int num);
|
||||
|
@ -221,6 +224,7 @@ public:
|
|||
// screen we are watching for modifier changes
|
||||
BScreen *watchingScreen() { return m_watching_screen; }
|
||||
const XEvent &lastEvent() const { return m_last_event; }
|
||||
|
||||
private:
|
||||
|
||||
typedef struct MenuTimestamp {
|
||||
|
@ -232,8 +236,8 @@ private:
|
|||
|
||||
std::string getRcFilename();
|
||||
void load_rc();
|
||||
|
||||
void reload_rc();
|
||||
|
||||
void real_rereadMenu();
|
||||
void real_reconfigure();
|
||||
|
||||
|
@ -297,6 +301,9 @@ private:
|
|||
std::string m_rc_file; ///< resource filename
|
||||
char **m_argv;
|
||||
int m_argc;
|
||||
|
||||
std::string m_restart_argument; ///< what to restart
|
||||
|
||||
XEvent m_last_event;
|
||||
|
||||
FbTk::Timer m_reconfig_timer; ///< when we execute reconfig command we must wait at least to next event round
|
||||
|
@ -315,6 +322,7 @@ private:
|
|||
Toolbars m_toolbars;
|
||||
|
||||
bool m_starting;
|
||||
bool m_restarting;
|
||||
bool m_shutdown;
|
||||
int m_server_grabs;
|
||||
int m_randr_event_type; ///< the type number of randr event
|
||||
|
|
20
src/main.cc
20
src/main.cc
|
@ -20,7 +20,7 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// $Id: main.cc,v 1.32 2004/10/11 22:48:35 rathnor Exp $
|
||||
// $Id: main.cc,v 1.33 2004/10/18 01:26:54 akir Exp $
|
||||
|
||||
#include "fluxbox.hh"
|
||||
#include "version.h"
|
||||
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "FbTk/Theme.hh"
|
||||
#include "FbTk/I18n.hh"
|
||||
#include "FbTk/StringUtil.hh"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
|
@ -253,7 +254,7 @@ int main(int argc, char **argv) {
|
|||
fluxbox.reset(new Fluxbox(argc, argv, session_display.c_str(), rc_file.c_str()));
|
||||
fluxbox->eventLoop();
|
||||
|
||||
exitcode = EXIT_SUCCESS;
|
||||
exitcode = EXIT_SUCCESS;
|
||||
|
||||
} catch (std::out_of_range &oor) {
|
||||
cerr<<"Fluxbox: "<<_FBTEXT(main, ErrorOutOfRange, "Out of range", "Error message")<<": "<<oor.what()<<endl;
|
||||
|
@ -271,6 +272,10 @@ int main(int argc, char **argv) {
|
|||
cerr<<"Fluxbox: "<<_FBTEXT(main, ErrorUnknown, "Unknown error", "Error message")<<"."<<endl;
|
||||
abort();
|
||||
}
|
||||
|
||||
bool restarting = fluxbox->isRestarting();
|
||||
const std::string restart_argument(fluxbox->getRestartArgument());
|
||||
|
||||
// destroy fluxbox
|
||||
fluxbox.reset(0);
|
||||
|
||||
|
@ -280,5 +285,16 @@ int main(int argc, char **argv) {
|
|||
if (errbuf != 0)
|
||||
cerr.rdbuf(errbuf);
|
||||
|
||||
if (restarting) {
|
||||
if (restart_argument.c_str()) {
|
||||
execlp(restart_argument.c_str(), restart_argument.c_str(), 0);
|
||||
perror(restart_argument.c_str());
|
||||
}
|
||||
|
||||
// fall back in case the above execlp doesn't work
|
||||
execvp(argv[0], argv);
|
||||
execvp(FbTk::StringUtil::basename(argv[0]).c_str(), argv);
|
||||
}
|
||||
|
||||
return exitcode;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue