mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-10 00:59:10 +08:00
Search: Fixed returning of a pointer to temporary.
This commit is contained in:
parent
2875bc685c
commit
cc2d33f6a0
@ -89,15 +89,10 @@ FMFlag Option::fuzzy_match(const std::string& search, int& outScore) const
|
|||||||
return fuzzy_match(search_pattern, outScore);
|
return fuzzy_match(search_pattern, outScore);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FoundOption::get_label(const char** out_text) const
|
|
||||||
{
|
|
||||||
*out_text = label.utf8_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
void FoundOption::get_marked_label_and_tooltip(const char** label_, const char** tooltip_) const
|
void FoundOption::get_marked_label_and_tooltip(const char** label_, const char** tooltip_) const
|
||||||
{
|
{
|
||||||
*label_ = marked_label.utf8_str();
|
*label_ = marked_label.c_str();
|
||||||
*tooltip_ = tooltip.utf8_str();
|
*tooltip_ = tooltip.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
@ -254,8 +249,8 @@ bool OptionsSearcher::search(const std::string& search, bool force/* = false*/)
|
|||||||
{
|
{
|
||||||
const Option &opt = options[i];
|
const Option &opt = options[i];
|
||||||
if (full_list) {
|
if (full_list) {
|
||||||
wxString label = get_label(opt);
|
std::string label = into_u8(get_label(opt));
|
||||||
found.emplace_back(FoundOption{ label, label, get_tooltip(opt), i, 0 });
|
found.emplace_back(FoundOption{ label, label, into_u8(get_tooltip(opt)), i, 0 });
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,7 +270,7 @@ bool OptionsSearcher::search(const std::string& search, bool force/* = false*/)
|
|||||||
mark_string(marked_label, from_u8(search));
|
mark_string(marked_label, from_u8(search));
|
||||||
clear_marked_string(marked_label);
|
clear_marked_string(marked_label);
|
||||||
|
|
||||||
found.emplace_back(FoundOption{ label, marked_label, get_tooltip(opt), i, score });
|
found.emplace_back(FoundOption{ into_u8(label), into_u8(marked_label), into_u8(get_tooltip(opt)), i, score });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,7 +352,7 @@ bool SearchComboPopup::Create(wxWindow* parent)
|
|||||||
void SearchComboPopup::SetStringValue(const wxString& s)
|
void SearchComboPopup::SetStringValue(const wxString& s)
|
||||||
{
|
{
|
||||||
int n = wxListBox::FindString(s);
|
int n = wxListBox::FindString(s);
|
||||||
if (n >= 0 && n < wxListBox::GetCount())
|
if (n >= 0 && n < int(wxListBox::GetCount()))
|
||||||
wxListBox::Select(n);
|
wxListBox::Select(n);
|
||||||
|
|
||||||
// save a combo control's string
|
// save a combo control's string
|
||||||
@ -549,7 +544,7 @@ void SearchDialog::update_list()
|
|||||||
|
|
||||||
const std::vector<FoundOption>& filters = searcher->found_options();
|
const std::vector<FoundOption>& filters = searcher->found_options();
|
||||||
for (const FoundOption& item : filters)
|
for (const FoundOption& item : filters)
|
||||||
search_list->Append(item.label);
|
search_list->Append(from_u8(item.label));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchDialog::OnKeyDown(wxKeyEvent& event)
|
void SearchDialog::OnKeyDown(wxKeyEvent& event)
|
||||||
|
@ -71,13 +71,13 @@ struct Option {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct FoundOption {
|
struct FoundOption {
|
||||||
wxString label;
|
std::string label;
|
||||||
wxString marked_label;
|
std::string marked_label;
|
||||||
wxString tooltip;
|
std::string tooltip;
|
||||||
size_t option_idx {0};
|
size_t option_idx {0};
|
||||||
int outScore {0};
|
int outScore {0};
|
||||||
|
|
||||||
void get_label(const char** out_text) const;
|
// Returning pointers to contents of std::string members, to be used by ImGUI for rendering.
|
||||||
void get_marked_label_and_tooltip(const char** label, const char** tooltip) const;
|
void get_marked_label_and_tooltip(const char** label, const char** tooltip) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "BonjourDialog.hpp"
|
#include "BonjourDialog.hpp"
|
||||||
#include "WipeTowerDialog.hpp"
|
#include "WipeTowerDialog.hpp"
|
||||||
#include "ButtonsDescription.hpp"
|
#include "ButtonsDescription.hpp"
|
||||||
|
#include "Search.hpp"
|
||||||
|
|
||||||
#include <wx/app.h>
|
#include <wx/app.h>
|
||||||
#include <wx/button.h>
|
#include <wx/button.h>
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
#include "Event.hpp"
|
#include "Event.hpp"
|
||||||
#include "wxExtensions.hpp"
|
#include "wxExtensions.hpp"
|
||||||
#include "ConfigManipulation.hpp"
|
#include "ConfigManipulation.hpp"
|
||||||
#include "Search.hpp"
|
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user