enforce singleton nature of Splash a little more rigorously, and slightly rationalize it's use

This commit is contained in:
Paul Davis 2019-10-11 14:29:55 -06:00
parent da2d6312c4
commit 54acf6af6a
7 changed files with 36 additions and 44 deletions

View file

@ -341,7 +341,6 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir)
, midi_port_matrix (X_("midi-connection-manager"), _("MIDI Connections"), boost::bind (&ARDOUR_UI::create_global_port_matrix, this, ARDOUR::DataType::MIDI)) , midi_port_matrix (X_("midi-connection-manager"), _("MIDI Connections"), boost::bind (&ARDOUR_UI::create_global_port_matrix, this, ARDOUR::DataType::MIDI))
, key_editor (X_("key-editor"), _("Keyboard Shortcuts"), boost::bind (&ARDOUR_UI::create_key_editor, this)) , key_editor (X_("key-editor"), _("Keyboard Shortcuts"), boost::bind (&ARDOUR_UI::create_key_editor, this))
, video_server_process (0) , video_server_process (0)
, splash (0)
, have_configure_timeout (false) , have_configure_timeout (false)
, last_configure_time (0) , last_configure_time (0)
, last_peak_grab (0) , last_peak_grab (0)

View file

@ -190,8 +190,8 @@ public:
bool run_startup (bool should_be_new, std::string load_template); bool run_startup (bool should_be_new, std::string load_template);
void show_splash ();
void hide_splash (); void hide_splash ();
static void pop_back_splash (Gtk::Window&);
void launch_chat (); void launch_chat ();
void launch_manual (); void launch_manual ();
@ -752,10 +752,6 @@ private:
uint32_t rec_enabled_streams; uint32_t rec_enabled_streams;
void count_recenabled_streams (ARDOUR::Route&); void count_recenabled_streams (ARDOUR::Route&);
Splash* splash;
void pop_back_splash (Gtk::Window&);
/* cleanup */ /* cleanup */
Gtk::MenuItem *cleanup_item; Gtk::MenuItem *cleanup_item;
@ -820,8 +816,6 @@ private:
Gtk::Label status_bar_label; Gtk::Label status_bar_label;
bool status_bar_button_press (GdkEventButton*); bool status_bar_button_press (GdkEventButton*);
void loading_message (const std::string& msg);
PBD::ScopedConnectionList forever_connections; PBD::ScopedConnectionList forever_connections;
PBD::ScopedConnection halt_connection; PBD::ScopedConnection halt_connection;
PBD::ScopedConnection editor_meter_connection; PBD::ScopedConnection editor_meter_connection;

View file

@ -352,7 +352,7 @@ ARDOUR_UI::load_session (const std::string& path, const std::string& snap_name,
} }
} }
loading_message (string_compose (_("Please wait while %1 loads your session"), PROGRAM_NAME)); BootMessage (string_compose (_("Please wait while %1 loads your session"), PROGRAM_NAME));
try { try {
new_session = new Session (*AudioEngine::instance(), path, snap_name, 0, mix_template); new_session = new Session (*AudioEngine::instance(), path, snap_name, 0, mix_template);

View file

@ -325,40 +325,10 @@ ARDOUR_UI::keyboard_settings () const
return node; return node;
} }
void
ARDOUR_UI::loading_message (const std::string& msg)
{
if (ARDOUR_COMMAND_LINE::no_splash) {
return;
}
if (!splash) {
show_splash ();
}
splash->message (msg);
}
void
ARDOUR_UI::show_splash ()
{
if (splash == 0) {
try {
splash = new Splash;
} catch (...) {
return;
}
}
splash->display ();
}
void void
ARDOUR_UI::hide_splash () ARDOUR_UI::hide_splash ()
{ {
delete splash; Splash::drop ();
splash = 0;
} }
void void

View file

@ -48,6 +48,28 @@ using namespace ARDOUR;
Splash* Splash::the_splash = 0; Splash* Splash::the_splash = 0;
Splash*
Splash::instance()
{
if (!the_splash) {
the_splash = new Splash;
}
return the_splash;
}
bool
Splash::exists ()
{
return the_splash;
}
void
Splash::drop ()
{
delete the_splash;
the_splash = 0;
}
Splash::Splash () Splash::Splash ()
{ {
assert (the_splash == 0); assert (the_splash == 0);
@ -208,6 +230,9 @@ Splash::expose (GdkEventExpose* ev)
void void
Splash::boot_message (std::string msg) Splash::boot_message (std::string msg)
{ {
if (!is_visible()) {
display ();
}
message (msg); message (msg);
} }

View file

@ -34,10 +34,11 @@ class ARDOUR_UI;
class Splash : public Gtk::Window class Splash : public Gtk::Window
{ {
public: public:
Splash ();
~Splash (); ~Splash ();
static Splash* instance() { return the_splash; } static Splash* instance();
static void drop();
static bool exists ();
void display (); void display ();
void pop_back_for (Gtk::Window&); void pop_back_for (Gtk::Window&);
@ -51,6 +52,7 @@ public:
void hide (); void hide ();
private: private:
Splash ();
static Splash* the_splash; static Splash* the_splash;
Glib::RefPtr<Gdk::Pixbuf> pixbuf; Glib::RefPtr<Gdk::Pixbuf> pixbuf;

View file

@ -42,6 +42,7 @@
#include "gtkmm2ext/application.h" #include "gtkmm2ext/application.h"
#include <gtkmm2ext/doi.h> #include <gtkmm2ext/doi.h>
#include "ardour_ui.h"
#include "engine_dialog.h" #include "engine_dialog.h"
#include "new_user_wizard.h" #include "new_user_wizard.h"
#include "opts.h" #include "opts.h"
@ -569,7 +570,7 @@ StartupFSM::check_session_parameters (bool must_be_new)
/* does not exist at present */ /* does not exist at present */
if (!requested_new) { if (!requested_new) {
// pop_back_splash (session_dialog); ARDOUR_UI::pop_back_splash (*session_dialog);
MessageDialog msg (string_compose (_("There is no existing session at \"%1\""), session_path)); MessageDialog msg (string_compose (_("There is no existing session at \"%1\""), session_path));
msg.run (); msg.run ();
session_dialog->clear_name(); session_dialog->clear_name();
@ -714,7 +715,7 @@ StartupFSM::ask_about_loading_existing_session (const std::string& session_path)
msg.set_title (_("Open Existing Session")); msg.set_title (_("Open Existing Session"));
msg.set_wmclass (X_("existing_session"), PROGRAM_NAME); msg.set_wmclass (X_("existing_session"), PROGRAM_NAME);
msg.set_position (Gtk::WIN_POS_CENTER); msg.set_position (Gtk::WIN_POS_CENTER);
// pop_back_splash (msg); ARDOUR_UI::pop_back_splash (msg);
switch (msg.run()) { switch (msg.run()) {
case RESPONSE_YES: case RESPONSE_YES:
@ -761,3 +762,4 @@ Full information on all the above can be found on the support page at\n\
pre_release_dialog->set_position (WIN_POS_CENTER); pre_release_dialog->set_position (WIN_POS_CENTER);
pre_release_dialog->present (); pre_release_dialog->present ();
} }