diff --git a/aegisub/dialog_options.cpp b/aegisub/dialog_options.cpp index 1812a0b34..06b00999a 100644 --- a/aegisub/dialog_options.cpp +++ b/aegisub/dialog_options.cpp @@ -745,8 +745,9 @@ void DialogOptions::OnOK(wxCommandEvent &event) { if (answer == wxYES) { FrameMain *frame = (FrameMain*) GetParent(); if (frame->Close()) { - wxStandardPaths stand; - wxExecute(stand.GetExecutablePath()); + RestartAegisub(); + //wxStandardPaths stand; + //wxExecute(stand.GetExecutablePath()); } } } @@ -778,8 +779,9 @@ void DialogOptions::OnCancel(wxCommandEvent &event) { if (answer == wxYES) { FrameMain *frame = (FrameMain*) GetParent(); if (frame->Close()) { - wxStandardPaths stand; - wxExecute(stand.GetExecutablePath()); + RestartAegisub(); + //wxStandardPaths stand; + //wxExecute(stand.GetExecutablePath()); } } } @@ -921,8 +923,9 @@ void DialogOptions::WriteToOptions(bool justApply) { if (answer == wxYES) { FrameMain *frame = (FrameMain*) GetParent(); if (frame->Close()) { - wxStandardPaths stand; - wxExecute(stand.GetExecutablePath()); + RestartAegisub(); + //wxStandardPaths stand; + //wxExecute(stand.GetExecutablePath()); } } } diff --git a/aegisub/frame_main_events.cpp b/aegisub/frame_main_events.cpp index 35a105cc8..bea467db6 100644 --- a/aegisub/frame_main_events.cpp +++ b/aegisub/frame_main_events.cpp @@ -532,8 +532,9 @@ void FrameMain::OnOpenRecentAudio(wxCommandEvent &event) { /////////////////// // Open new Window void FrameMain::OnNewWindow(wxCommandEvent& WXUNUSED(event)) { - wxStandardPaths stand; - wxExecute(stand.GetExecutablePath()); + RestartAegisub(); + //wxStandardPaths stand; + //wxExecute(stand.GetExecutablePath()); } @@ -1675,8 +1676,9 @@ void FrameMain::OnChooseLanguage (wxCommandEvent &event) { if (result == wxYES) { // Restart Aegisub if (Close()) { - wxStandardPaths stand; - wxExecute(_T("\"") + stand.GetExecutablePath() + _T("\"")); + RestartAegisub(); + //wxStandardPaths stand; + //wxExecute(_T("\"") + stand.GetExecutablePath() + _T("\"")); } } } diff --git a/aegisub/utils.cpp b/aegisub/utils.cpp index e1de6d4db..0d7c0d435 100644 --- a/aegisub/utils.cpp +++ b/aegisub/utils.cpp @@ -42,10 +42,14 @@ #include #include #include +#include #include "utils.h" #ifdef __UNIX__ #include #endif +#ifdef __APPLE__ +#include "libosxutil/libosxutil.h" +#endif #ifndef __LINUX__ @@ -379,3 +383,21 @@ wxIcon BitmapToIcon(wxBitmap iconBmp) { ico.CopyFromBitmap(bmp); return ico; } + +/////////////////////// +// Start Aegisub again +// It is assumed that something has prepared closing the current instance +// just before this is called. +void RestartAegisub() { +#if defined(__WXMSW__) + wxStandardPaths stand; + wxExecute(_T("\"") + stand.GetExecutablePath() + _T("\"")); +#elif defined(__WXMAC__) + char *bundle_path = OSX_GetBundlePath(); + if (!bundle_path) return; // oops + wxExecute(wxString::Format(_T("/usr/bin/open \"%s\""), wxString(bundle_path, wxConvUTF8))); + free(bundle_path); +#else + // someone fix this +#endif +} diff --git a/aegisub/utils.h b/aegisub/utils.h index 45720e15f..68ed756f2 100644 --- a/aegisub/utils.h +++ b/aegisub/utils.h @@ -1,4 +1,4 @@ -// Copyright (c) 2005, Rodrigo Braz Monteiro +// Copyright (c) 2005-2009, Rodrigo Braz Monteiro, Niels Martin Hansen // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -71,6 +71,7 @@ void GetWordBoundaries(const wxString text,IntPairVector &results,int start=0,in int StringToInt(const wxString &str,int start=0,int end=-1); int StringToFix(const wxString &str,size_t decimalPlaces,int start=0,int end=-1); wxIcon BitmapToIcon(wxBitmap bmp); +void RestartAegisub(); //////////