[DEBUG] correct the bug of close file and open again ar seg-fault when write

This commit is contained in:
Edouard DUPIN 2016-03-15 22:33:06 +01:00
parent a265735cd1
commit c251a419ad
3 changed files with 14 additions and 17 deletions

View File

@ -70,24 +70,24 @@ void appl::WorkerCloseFile::startAction(const std::string& _bufferName) {
destroy();
return;
}
tmpPopUp->setTitle("<bold>Close un-saved file:</bold>");
tmpPopUp->setComment("The file named : <i>\"" + m_buffer->getFileName() + "\"</i> is curently modify. <br/>If you don't saves these modifications,<br/>they will be definitly lost...");
tmpPopUp->setTitle("<bold>_T{Close un-saved file:}</bold>");
tmpPopUp->setComment("_T{The file named:} <i>'" + m_buffer->getFileName() + "'</i> _T{is curently modify.}<br/>_T{If you don't saves these modifications,}<br/>_T{they will be definitly lost...}");
std::shared_ptr<ewol::widget::Button> bt = nullptr;
if (m_buffer->hasFileName() == true) {
bt = tmpPopUp->addButton("Save", true);
bt = tmpPopUp->addButton("_T{Save}", true);
if (bt != nullptr) {
bt->signalPressed.connect(shared_from_this(), &appl::WorkerCloseFile::onCallbackSaveValidate);
}
}
bt = tmpPopUp->addButton("Save As", true);
bt = tmpPopUp->addButton("_T{Save As}", true);
if (bt != nullptr) {
bt->signalPressed.connect(shared_from_this(), &appl::WorkerCloseFile::onCallbackSaveAsValidate);
}
bt = tmpPopUp->addButton("Close", true);
bt = tmpPopUp->addButton("_T{Close}", true);
if (bt != nullptr) {
bt->signalPressed.connect(shared_from_this(), &appl::WorkerCloseFile::onCallbackClose);
}
bt = tmpPopUp->addButton("Cancel", true);
bt = tmpPopUp->addButton("_T{Cancel}", true);
if (bt != nullptr) {
bt->signalPressed.connect(shared_from_this(), &appl::WorkerCloseFile::onCallbackCancel);
}

View File

@ -66,8 +66,8 @@ void appl::WorkerSaveFile::init() {
destroy();
return;
}
m_chooser->propertyLabelTitle.set("Save files As...");
m_chooser->propertyLabelValidate.set("Save");
m_chooser->propertyLabelTitle.set("_T{Save files As...}");
m_chooser->propertyLabelValidate.set("_T{Save}");
etk::FSNode tmpName(*propertyBufferName);
m_chooser->propertyPath.set(tmpName.getNameFolder());
m_chooser->propertyFile.set(tmpName.getNameFile());

View File

@ -28,36 +28,33 @@ namespace appl {
for (size_t iii = 0; iii < m_specificData.size() ; ++iii) {
if (m_specificData[iii].second != nullptr) {
remove(*m_specificData[iii].second);
delete(m_specificData[iii].second);
m_specificData[iii].second = nullptr;
}
}
m_specificData.clear();
}
private:
std::vector<std::pair<std::weak_ptr<appl::Buffer> ,TYPE* >> m_specificData;
std::vector<std::pair<std::weak_ptr<appl::Buffer> ,std::unique_ptr<TYPE>>> m_specificData;
protected:
TYPE* getDataRef(appl::TextViewer& _textDrawer) {
auto it = m_specificData.begin();
while(it != m_specificData.end()) {
std::shared_ptr<appl::Buffer> buf = it->first.lock();
if (buf == nullptr) {
delete(it->second);
it->second = nullptr;
it = m_specificData.erase(it);
continue;
}
if (buf == _textDrawer.internalGetBuffer()) {
return it->second;
return it->second.get();
}
++it;
}
TYPE* data = new TYPE();
std::unique_ptr<TYPE> data(new TYPE());
if (data == nullptr) {
return nullptr;
}
m_specificData.push_back(std::make_pair(_textDrawer.internalGetBuffer(), data));
m_specificData.push_back(std::make_pair(_textDrawer.internalGetBuffer(), std::move(data)));
// create a new one ...
return data;
return data.get();
}
protected: // Wrap all element with their internal data: (do not use theses function)
bool onReceiveShortCut(appl::TextViewer& _textDrawer,