Skip to content

Commit

Permalink
Fix a bunch of compile errors after refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
arch1t3cht committed Nov 24, 2023
1 parent b899e07 commit 2582020
Show file tree
Hide file tree
Showing 19 changed files with 26 additions and 32 deletions.
2 changes: 2 additions & 0 deletions libaegisub/meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
libaegisub_src = [
'ass/dialogue_parser.cpp',
'ass/karaoke.cpp',
'ass/time.cpp',
'ass/uuencode.cpp',

Expand Down Expand Up @@ -34,6 +35,7 @@ libaegisub_src = [
'common/parser.cpp',
'common/path.cpp',
'common/thesaurus.cpp',
'common/unicode.cpp',
'common/util.cpp',
'common/vfr.cpp',
'common/ycbcr_conv.cpp',
Expand Down
1 change: 0 additions & 1 deletion libaegisub/windows/log_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "libaegisub/log.h"

#include "libaegisub/charset_conv_win.h"
#include "libaegisub/make_unique.h"

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
Expand Down
1 change: 0 additions & 1 deletion libaegisub/windows/path_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <libaegisub/path.h>

#include <libaegisub/exception.h>
#include <libaegisub/make_unique.h>

#include <boost/filesystem.hpp>

Expand Down
3 changes: 1 addition & 2 deletions src/audio_player_alsa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@

#include <libaegisub/audio/provider.h>
#include <libaegisub/log.h>
#include <libaegisub/make_unique.h>

#include <atomic>
#include <algorithm>
Expand Down Expand Up @@ -349,7 +348,7 @@ int64_t AlsaPlayer::GetCurrentPosition()

std::unique_ptr<AudioPlayer> CreateAlsaPlayer(agi::AudioProvider *provider, wxWindow *)
{
return agi::make_unique<AlsaPlayer>(provider);
return std::make_unique<AlsaPlayer>(provider);
}

#endif // WITH_ALSA
3 changes: 1 addition & 2 deletions src/audio_player_dsound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@

#include <libaegisub/audio/provider.h>
#include <libaegisub/log.h>
#include <libaegisub/make_unique.h>

#include <mmsystem.h>
#include <dsound.h>
Expand Down Expand Up @@ -368,7 +367,7 @@ void DirectSoundPlayerThread::Stop() {
}

std::unique_ptr<AudioPlayer> CreateDirectSoundPlayer(agi::AudioProvider *provider, wxWindow *parent) {
return agi::make_unique<DirectSoundPlayer>(provider, parent);
return std::make_unique<DirectSoundPlayer>(provider, parent);
}

#endif // WITH_DIRECTSOUND
5 changes: 2 additions & 3 deletions src/audio_player_dsound2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#include <libaegisub/audio/provider.h>
#include <libaegisub/scoped_ptr.h>
#include <libaegisub/log.h>
#include <libaegisub/make_unique.h>

#include <mmsystem.h>
#include <process.h>
Expand Down Expand Up @@ -814,7 +813,7 @@ DirectSoundPlayer2::DirectSoundPlayer2(agi::AudioProvider *provider, wxWindow *p

try
{
thread = agi::make_unique<DirectSoundPlayer2Thread>(provider, WantedLatency, BufferLength, parent);
thread = std::make_unique<DirectSoundPlayer2Thread>(provider, WantedLatency, BufferLength, parent);
}
catch (const char *msg)
{
Expand Down Expand Up @@ -929,7 +928,7 @@ void DirectSoundPlayer2::SetVolume(double vol)
}

std::unique_ptr<AudioPlayer> CreateDirectSound2Player(agi::AudioProvider *provider, wxWindow *parent) {
return agi::make_unique<DirectSoundPlayer2>(provider, parent);
return std::make_unique<DirectSoundPlayer2>(provider, parent);
}

#endif // WITH_DIRECTSOUND
5 changes: 2 additions & 3 deletions src/audio_player_oss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@

#include <libaegisub/audio/provider.h>
#include <libaegisub/log.h>
#include <libaegisub/make_unique.h>

#include <fcntl.h>
#include <sys/ioctl.h>
Expand Down Expand Up @@ -198,7 +197,7 @@ void OSSPlayer::Play(int64_t start, int64_t count)
start_frame = cur_frame = start;
end_frame = start + count;

thread = agi::make_unique<OSSPlayerThread>(this);
thread = std::make_unique<OSSPlayerThread>(this);
thread->Create();
thread->Run();

Expand Down Expand Up @@ -280,7 +279,7 @@ int64_t OSSPlayer::GetCurrentPosition()
}

std::unique_ptr<AudioPlayer> CreateOSSPlayer(agi::AudioProvider *provider, wxWindow *) {
return agi::make_unique<OSSPlayer>(provider);
return std::make_unique<OSSPlayer>(provider);
}

#endif // WITH_OSS
3 changes: 1 addition & 2 deletions src/audio_player_portaudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@

#include <libaegisub/audio/provider.h>
#include <libaegisub/log.h>
#include <libaegisub/make_unique.h>

// Uncomment to enable extremely spammy debug logging
//#define PORTAUDIO_DEBUG
Expand Down Expand Up @@ -280,7 +279,7 @@ bool PortAudioPlayer::IsPlaying() {
}

std::unique_ptr<AudioPlayer> CreatePortAudioPlayer(agi::AudioProvider *provider, wxWindow *) {
return agi::make_unique<PortAudioPlayer>(provider);
return std::make_unique<PortAudioPlayer>(provider);
}

#endif // WITH_PORTAUDIO
3 changes: 1 addition & 2 deletions src/audio_player_pulse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@

#include <libaegisub/audio/provider.h>
#include <libaegisub/log.h>
#include <libaegisub/make_unique.h>

#include <cstdio>
#include <pulse/pulseaudio.h>
Expand Down Expand Up @@ -322,6 +321,6 @@ void PulseAudioPlayer::pa_stream_notify(pa_stream *p, PulseAudioPlayer *thread)
}

std::unique_ptr<AudioPlayer> CreatePulseAudioPlayer(agi::AudioProvider *provider, wxWindow *) {
return agi::make_unique<PulseAudioPlayer>(provider);
return std::make_unique<PulseAudioPlayer>(provider);
}
#endif // WITH_LIBPULSE
3 changes: 1 addition & 2 deletions src/audio_provider_avs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
#include <libaegisub/charset_conv.h>
#include <libaegisub/fs.h>
#include <libaegisub/path.h>
#include <libaegisub/make_unique.h>

#include <mutex>

Expand Down Expand Up @@ -144,6 +143,6 @@ void AvisynthAudioProvider::FillBuffer(void *buf, int64_t start, int64_t count)
}

std::unique_ptr<agi::AudioProvider> CreateAvisynthAudioProvider(std::filesystem::path const& file, agi::BackgroundRunner *) {
return agi::make_unique<AvisynthAudioProvider>(file);
return std::make_unique<AvisynthAudioProvider>(file);
}
#endif
4 changes: 2 additions & 2 deletions src/dialog_shift_times.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,12 @@ void DialogShiftTimes::OnHistoryClick(wxCommandEvent &evt) {

json::Object& obj = history[entry];
if (obj["is by time"]) {
shift_time->SetTime(agi::Time((std::string_view)obj["amount"]));
shift_time->SetTime(agi::Time((std::string)obj["amount"]));

This comment has been minimized.

Copy link
@CoffeeFlux

CoffeeFlux Nov 24, 2023

Member

Isn't this wrong? agi::Time takes in a string_view now.

This comment has been minimized.

Copy link
@arch1t3cht

arch1t3cht Nov 24, 2023

Author Member

The error was that json::UnknownElement didn't have a cast to std::string_view implemented. Seems like that cast was defined, but not actually implemented, so it'd compile but fail when linking. Though this could also be fixed by just implementing that string_view cast instead.

shift_by_time->SetValue(true);
OnByTime(evt);
}
else {
shift_frames->SetValue(to_wx((std::string_view)obj["amount"]));
shift_frames->SetValue(to_wx((std::string)obj["amount"]));

This comment has been minimized.

Copy link
@CoffeeFlux

CoffeeFlux Nov 24, 2023

Member

This should have a string_view overload too

if (shift_by_frames->IsEnabled()) {
shift_by_frames->SetValue(true);
OnByFrames(evt);
Expand Down
5 changes: 4 additions & 1 deletion src/ffmpegsource_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
#include <wx/intl.h>
#include <wx/choicdlg.h>

#include <chrono>

FFmpegSourceProvider::FFmpegSourceProvider(agi::BackgroundRunner *br)
: br(br)
{
Expand Down Expand Up @@ -187,7 +189,8 @@ std::filesystem::path FFmpegSourceProvider::GetCacheFilename(std::filesystem::pa
hash.process_bytes(filename.string().c_str(), filename.string().size());

// Generate the filename
auto result = config::path->Decode(agi::Str("?local/ffms2cache/", std::to_string(hash.checksum()), "_", std::to_string(len), "_", std::to_string(agi::fs::ModifiedTime(filename)), ".ffindex");
auto modified_time = std::chrono::duration_cast<std::chrono::seconds>(agi::fs::ModifiedTime(filename).time_since_epoch()).count();
auto result = config::path->Decode(agi::Str("?local/ffms2cache/", std::to_string(hash.checksum()), "_", std::to_string(len), "_", std::to_string(modified_time), ".ffindex"));

// Ensure that folder exists
agi::fs::CreateDirectory(result.parent_path());
Expand Down
2 changes: 1 addition & 1 deletion src/ffmpegsource_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
///

#ifdef WITH_FFMS2
#include <filesystem>
#include <map>

#include <ffms.h>

#include <libaegisub/fs_fwd.h>
#include <libaegisub/scoped_ptr.h>

namespace agi { class BackgroundRunner; }
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static const char *LastStartupState = nullptr;
#endif

void AegisubApp::OnAssertFailure(const wxChar *file, int line, const wxChar *func, const wxChar *cond, const wxChar *msg) {
LOG_A("wx/assert") << file << ":" << line << ":" << func << "() " << cond << ": " << msg;
LOG_A("wx/assert") << wxString(file) << ":" << line << ":" << wxString(func) << "() " << wxString(cond) << ": " << wxString(msg);
wxApp::OnAssertFailure(file, line, func, cond, msg);
}

Expand Down
2 changes: 1 addition & 1 deletion src/spellchecker_hunspell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void HunspellSpellChecker::AddWord(std::string_view word) {
hunspell->add(conv->Convert(word).c_str());

// Add the word
if (customWords.insert(word).second)
if (customWords.insert(std::string(word)).second)
WriteUserDictionary();
}

Expand Down
2 changes: 1 addition & 1 deletion src/spellchecker_hunspell.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
#ifdef WITH_HUNSPELL
#include <libaegisub/spellchecker.h>

#include <libaegisub/fs_fwd.h>
#include <libaegisub/signal.h>

#include <filesystem>
#include <memory>
#include <set>

Expand Down
3 changes: 1 addition & 2 deletions src/subtitles_provider_csri.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#include "subtitle_format_ass.h"
#include "video_frame.h"

#include <libaegisub/make_unique.h>

#include <mutex>

Expand Down Expand Up @@ -122,7 +121,7 @@ std::vector<std::string> List() {
}

std::unique_ptr<SubtitlesProvider> Create(std::string const& name, agi::BackgroundRunner *) {
return agi::make_unique<CSRISubtitlesProvider>(name);
return std::make_unique<CSRISubtitlesProvider>(name);
}
}
#endif // WITH_CSRI
5 changes: 2 additions & 3 deletions src/video_provider_avs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include <libaegisub/fs.h>
#include <libaegisub/log.h>
#include <libaegisub/path.h>
#include <libaegisub/make_unique.h>

#include <boost/algorithm/string/predicate.hpp>
#include <mutex>
Expand Down Expand Up @@ -322,7 +321,7 @@ void AvisynthVideoProvider::GetFrame(int n, VideoFrame &out) {
}

namespace agi { class BackgroundRunner; }
std::unique_ptr<VideoProvider> CreateAvisynthVideoProvider(std::filesystem::path const& path, std::string const& colormatrix, agi::BackgroundRunner *) {
return agi::make_unique<AvisynthVideoProvider>(path, colormatrix);
std::unique_ptr<VideoProvider> CreateAvisynthVideoProvider(std::filesystem::path const& path, std::string_view colormatrix, agi::BackgroundRunner *) {
return std::make_unique<AvisynthVideoProvider>(path, std::string(colormatrix));
}
#endif // HAVE_AVISYNTH
4 changes: 2 additions & 2 deletions src/video_provider_ffmpegsource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,8 @@ void FFmpegSourceVideoProvider::GetFrame(int n, VideoFrame &out) {
}
}

std::unique_ptr<VideoProvider> CreateFFmpegSourceVideoProvider(std::filesystem::path const& path, std::string const& colormatrix, agi::BackgroundRunner *br) {
return std::make_unique<FFmpegSourceVideoProvider>(path, colormatrix, br);
std::unique_ptr<VideoProvider> CreateFFmpegSourceVideoProvider(std::filesystem::path const& path, std::string_view colormatrix, agi::BackgroundRunner *br) {
return std::make_unique<FFmpegSourceVideoProvider>(path, std::string(colormatrix), br);
}

#endif /* WITH_FFMS2 */

0 comments on commit 2582020

Please sign in to comment.